My schema looks something like this:
var ZoneSchema = new Schema({
name: String,
coupons: [{ type: Schema.Types.ObjectId, ref: 'Coupon' }],
magazines: [{ type: Schema.Types.ObjectId, ref: 'Magazine' }]
});
mongoose.model('Zone', ZoneSchema);
And I would then like to create a new zone like this, with the coupon and magazine arrays being empty initially:
var newZone = new Zone({
name: req.body.name,
coupons: [],
magazines: []
});
newZone.save(function(err) {
if(!err) {
res.send({ status: 'ok', message: 'success' });
}
else {
res.send(err);
}
});
But the callback for the save function is never getting executed, and it just hangs there forever until the request just times out with no errors. This is my first time working with references in Mongoose so I'm not sure if I'm doing something wrong here. Saving using other models that don't have references works fine.