So I have a key value object
project {
name: "",
createdBy: "some object id",
sharedWith: {
//here is a key value object to find by name
"645c9bfe68c1438ef182bc26": { write: true }
}
}
So I have to find all projects by key name, that project sharing with.
My request to this
I am doing it this way, and I have to apply some query filters to $or operator
return this.readProjectsQuery({
$or: [{ createdBy: userId }, { ??? }],
});
2
Answers
You may review your data model, using dynamic field names is a poor design. You can use this one:
Mongo Playground
Your project’s class or class instance method
readProjectsQuery
is unknown to us, but based on your shown data model and comments, you can find the documents you are looking for using a MongoDB query like this.Try it on mongoplayground.net.