Created
June 14, 2012 22:56
-
-
Save bingomanatee/2933515 to your computer and use it in GitHub Desktop.
Embedded Doc with _id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var friend_schema = new mongoose.Schema({ | |
_id:mongoose.Schema.ObjectId, | |
name:String | |
}); | |
var person_schema = new mongoose.Schema({ | |
name:String, | |
friends:[friend_schema] | |
}); | |
var Person_Model = mongoose.Model('Person', person_schema); | |
var person = new Person_Model({ | |
name:'Foo', | |
friends:[ | |
{ | |
name:'Bar' | |
}, | |
{ | |
name:'Sam' | |
} | |
] | |
}); | |
person.save(); | |
/** | |
* friends have no ID -- they appear as entered. | |
* { name: 'Foo', | |
_id: 4fda6be639bba80000000001, | |
friends: [ { name: 'Bar' }, { name: 'Sam' } ] } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment