We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/Automattic/mongoose/blob/master/docs/populate.md#dynamic-ref Going through this docs, I found the code might be somewhat misleading.
const commentSchema = new Schema({ body: { type: String, required: true }, modelId: { type: Schema.Types.ObjectId, required: true, // Instead of a hardcoded model name in `ref`, `refPath` means Mongoose // will look at the `onModel` property to find the right model. refPath: 'onModel' }, onModel: { type: String, required: true, enum: ['BlogPost', 'Product'] } }); ... const commentOnBook = await Comment.create({ body: 'Great read', doc: book._id, docModel: 'Product' }); const commentOnPost = await Comment.create({ body: 'Very informative', doc: post._id, docModel: 'BlogPost' });
I thought properties passed as 'doc' and 'docModel' would be transferred to 'modelId' and 'onModel'.
doc => modelId docModel => onModel
After some digging maybe it's just typos, please confirm.
The text was updated successfully, but these errors were encountered:
53d2625
No branches or pull requests
https://github.com/Automattic/mongoose/blob/master/docs/populate.md#dynamic-ref
Going through this docs, I found the code might be somewhat misleading.
I thought properties passed as 'doc' and 'docModel' would be transferred to 'modelId' and 'onModel'.
After some digging maybe it's just typos, please confirm.
The text was updated successfully, but these errors were encountered: