node.js - How to query for a specific property of a model of a specific model in mongoose? -
i new in mongoose, have 2 models: 1. user: has many todos in array. 2. todo has 1 field userid.
my problem not know how query specific todo specific user?
this code in graphql resolve:
resolve: async (root, args,context) => { console.log("newtodoid = ", args.newtodoid); const todoedgeadded = await usermodel.findone({ _id: context.user._id }).populate('todos').findone({_id: args.newtodoid}) // help? return { cursor: cursorforobjectinconnection(gettodos(), todo), node: todo, }; }, for gettodos(), need return todos. thinking of code:
await usermodel.findone({ _id: context.user._id }).populate('todos') as newbie in mongoose, appreciate code relevant question or links.
Comments
Post a Comment