I have two Schemas using SimpleSchema - say Schema1 and Schema2. I want to reference the internal ObjectId (_id) from Schema1 in Schema2. How do I go about doing this?
Schema1 looks like this:
Schema1 = new SimpleSchema({
aitem: {
type: String
},
anitem: {
type: String
}
});
Schema2 looks like this:
Schema2 = new SimpleSchema({
aaitem: {
type: String
},
aanitem: {
type: String
},
refItem: {
type: Mongo.ObjectID
}
});
When I try an insert in Meteor it says cannot validate ObjectID
Mongo.ObjectId is not an acceptable validator. The internal _id values are strings to JavaScript, so you can do: type: String
and that should work.