I have a schema that includes a field that is set to ObjectId. The field is set to the id of the document's parent. The document is not embedded in the parent. And, the field is not required.
I want to remove the parent in some cases so the document is at the root of hierarchy. Unfortunately, doing so results in a "Cast toObjectId failed ..." error.
What is the proper way to set the ObjectId to null or to remove the ObjectId?
I have tried to set the parent to undefined.
var self = this; var err = null; if(parentId){ self.parent = undefined; self.path = self.path.replace(parentId + pathSeparator, ''); } else { err = 'parent ID required'; } return cb(err, self); });
--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.