express-restify-mongoose: updating model has a problem, when model has array of objectId;
E.g: Schema for employee:
{
name: {type: String, default: 'Employee'},
company: [{type: mongoose.Schema.Types.ObjectId, ref: 'Company'}]
}
When an employee has two companies and I try to remove a company, so restify can not update the model.
i tried to change a little of source code (in operation.js) from:
var cleanBody = moredots(depopulate(req.body));
to:
var cleanBody = req.body;
it will work ok.
moredots(depopulate(req.body))
Returns a result like :
company.0 = "574afe60bce5048b69e17b18"
instead of
company = ["574afe60bce5048b69e17b18"]
I think there is a problem in depopulate function.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16
Commits related to this issue
- Fixes #294 and closes #298 - error when arrays of ObjectId's are updated by populated references — committed to tro3/express-restify-mongoose by deleted user 8 years ago
- Fix issue #294 (Rebase from #317) (#349) * Fixes #294 and closes #298 - error when arrays of ObjectId's are updated by populated references * Adding findOneAndUpdate = false tests * chore(misc)... — committed to florianholzapfel/express-restify-mongoose by Zertz 7 years ago
Great!
I merged (locally) your fix and tests into #314 and everything works – @Zertz do you want to merge these separately? Or is it alright if we bundle the fixes for both #294 and #305 into #314 ?