Open skarif2 opened 6 years ago
Try
Task.save(promotion)
Instead of
Task.save(Promotion, promotion)
Tried it. Getting the same error.
Can you put up the code for the Promotion model?
Promotion model: promotion.model.txt
BTW if I run bellow code and try to update only Merchant I get this error:
Error: Schema hasn't been registered for model \"Merchant\".\nUse mongoose.model(name, schema)
const Task = Fawn.Task();
Task
// .save(Promotion, promotion)
.update(Merchant, { _id: req.merchant._id }, {
// promotion: { $ojFuture: '0._id' }
})
.run({ useMongoose: true })
.then(() => {
res.json({
status: 'success',
message: 'Merchant promotion successfully added.'
});
})
.catch((err) => {
res.json({
status: 'error',
message: err.message
});
});
What version of Fawn are you using?
Fawn: 2.1.5
MongoDB: 3.6
It might be tied to the mongoose version #74
Fawn: 2.1.5
MongoDB: 3.6
Error: Schema hasn't been registered for model \"Promotion\".\nUse mongoose.model(name, schema)
My Code that is working:
Using Fawn which is not working:
Both the model has reference to each other. I know circular reference is bad but couldn't find any other easier way. And I am being extra cautious while populating references.
So, am I missing something? Is there any workaround?