have a Schema (called Event) with data that looks like this:
{ "_id" : ObjectId( "4f8dcb06ee21783d7400003c" ),
"venue" : ObjectId( "4f8dcb06ee21783d7400003b" ),
"name" : "Some event",
"webite: "www.whatever.com",
"attendees" : [
{ "_id" : ObjectId( "4f8dfb06ee21783d7134503a" ), "firstName" : "Joe", "lastName" : "Blogs", "emailAddress" : "so...@thing1.com" },
{ "_id" : ObjectId( "4f8dfb06ee21783d7134503b" ), "firstName" : "John", "lastName" : "West", "emailAddress" : "so...@thing2.com" }
{ "_id" : ObjectId( "4f8dfb06ee21783d7134503c" ), "firstName" : "Simon", "lastName" : "Green", "emailAddress" : "so...@thing3.com" }
{ "_id" : ObjectId( "4f8dfb06ee21783d7134503d" ), "firstName" : "Harry", "lastName" : "Smith", "emailAddress" : "so...@thing4.com" }
],
"eventType" : "Party"
}
How can I 'delete' the attendees object with id 4f8dfb06ee21783d7134503c?
Basically something like....
Event.findOne('attendees._id' : ObjectId('4f8dfb06ee21783d7134503c'), function(err, eventItem){
//delete the attendee embedded doc with id 4f8dfb06ee21783d7134503c
});
You could use popylate() and then just delete.
--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
Event.findOne('attendees._id' : ObjectId('4f8dfb06ee21783d7134503c'), function(err, eventItem){
eventItem.id('id_goes_here').remove() // this works....
});