我需要找到用户ID创建的所有对象, 这是对象的结构: createdBy._id:userId 如何找到由该用户ID创建的所有对象?
//sent from the vuex store
let filter = {createdBy: userId}
//inside the api at the backend
let criteria = {};
if(filterBy.createdBy) {
//it's true so it gets in here
criteria = `{"createdBy._id" : "${filterBy.createdBy}"}`
}
and then when i try to get it
const answer = await collection.find(criteria).toArray();
什么都没有。
在robo3t中,当我编写find({“ createdBy._id”:“ 5d308a5950f3d20f88d2b1d6”})时会找到它
答案 0 :(得分:0)
nvm,刚刚通过使用条件[“ createdBy._id”] = filterBy.createdBy;