node.js - Mongoose - Defining child's ObjectID in another Schema -
There is a similar thread @ However, instead of solving this it goes from another method. The second method or part of my title is.
Edit - Ignore this section, I am currently using alternate. The problem now refers to a child's object ID elsewhere.
I have the following array:
Selection: [{4433d18d31f3775756ac2a70: "542e91aa31f3775756abccda"}, {4433d18d31f3775756ac2a71: "542e916c31f3775756abccd8"}, {4433d18d31f3775756ac2a72: "542e934231f3775756abccdb"}]
My schema at this time is as follows:
Selection: {& LT; Some & gt;: {type: mongoose.Schema.Types.ObjectId, ref: 'choice'}}
place in
Alternatively, as this Internet does not seem possible after modification, I can have the following schema:
Selection: {PID: {type: mongoose.Schema.Types.ObjectId, Ref: 'Competition.CHILD'} Selection: {type: mongoose.Schema.Types .ObjectId, Ref: 'Election'}}
But the point here is that ObjectID is being used, where & lt; Some & gt;
A child is inside the schema schema competition, and I am saying that there can not be a way to do it for item id
. Any advice / support would be great, ideally I prefer the first solution but I think this is not possible. Thanks!
Use an array of objects with optional (but fixed) keys:
Selection: [ {Selection: {Type: ObjectId, Ref: 'Election'}, Children: {Type: ObjectId, Ref: 'Competition.CHILD'}}]
This gives you better inquiries, Enables the use of the population.
Comments
Post a Comment