MongoDB update document property array of strings $push if not present $pull if present
DATA = [ { name: ‘one’, example: { arrayOfStrings: [‘one’, ‘two’, ‘three’] } } ] db.getCollection(‘test’).update( {name: ‘one’}, [ { // From access.roles, if value is not there, then add it to array of strings. // if it is there, remove it from the array of strings. } ] ) Something like below, but working. […]
I need to merge base record data with two layers of edits in different collections
I have one collection that contains some base record data, for example:
How To Query Unknown Key’s Value Documents With Nested Structure in MongoDB?
I have a problem with querying with MongoDB, here’s the data structure in MongoDB: { “_id”: “aaaaa”, “groups”: [ { “name”: “group0”, “props”: { “unknown1”: “value1”, “unknown2”: “value2”, “unknown3”: “value3” } }, { “name”: “group1”, “props”: { “unknown4”: “value4”, “unknown5”: “value5”, “unknown6”: “value6” } } ] } I want to query documents whose nested fields […]
How to make a multiple match into an aggregate comparing the full string on MongoDB?
I’m trying to make a $and
clause within a $match
clause. This $and
clause should have a full complete comparison against the string I’m providing. I’d like to make sure that the comparisong with attributes.value
should be exact the string I’m passing. With the following expression:
mongodb query $match if tenary to field
i have a query in mongodb, i want to get from collection by specific field the field is “private.group” and its boolean.
i want the $match will be dynamic to pass is as varible (pass is true or false) and then make this query work as private group or public group.
how can i make this if tenary work in $match?
i can pass parameter to the function but its not work with if tenary
i mean this line of group.private
How to group multiple array by teacherId,scoreTypeId,studentId and subjectId?
I have collection score and scoreDetail that i want to group by multiple array by teacherId,scoreTypeId,studentId and subjectId for each I try to used aggregate but it still is wrong I had no idea. I have manage to group the array but I don’t know how to group the data so please help me
MongoDB Aggregation nested $group
I am trying to group and sub-group