I have the following code for mongoose schemes
var EstacionSchema = new Schema({
nombre : {type : String, required: true, unique: true}
, zona : {type : String, required: true}
, rutas : [Ruta]
})
mongoose.model('Estacion', EstacionSchema)
var RutaSchema = new Schema({
nombre : {type : String, required: true, unique: true, uppercase: true}
, estaciones : [Estacion]
})
mongoose.model('Ruta', RutaSchema)
however, when I try, it shows
ReferenceError: Ruta is not defined
I'm not sure how to handle this circular pattern when declaring models in mongoose or handle Many to Many relationships
source
share