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

Most upvoted comments

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 ?