db.collection_name.aggregate([
{$addFields: {
list: {$filter: {
input: '$array_field_name',
as: 'item',
cond: {
$gt: [
'$$item.array_subfield_name',
value
]
}
}}
}}
]);
db.collection_name.aggregate([
{$addFields: {
list: {$filter: {
input: '$array_field_name',
as: 'item',
cond: {
$gt: [
'$$item.array_subfield_name',
value
]
}
}}
}}
]);
db.runCommand({
update: "collection_name",
updates: [
{
q: {
"field1": "value1",
"field2": "value2",
},
u: {
$set: {
"field3": "value3",
},
multi: false,
upsert: false,
}
}
],
});
db.collection.aggregate([
{$match: {
$expr: { $ne: [ {$isArray: "$field_to_check"}, true] }
}}
]);
db.collection_name.find({
$nor: [
{$and: [
{"field1": "value"},
{"field2.subfield": "value"},
]}
]
});
db.COLLECTION_NAME.update(
{
FIELD_1: ANY_VALUE,
},
[
{$set: {
"NEW_FIELD_COPY": "$ORIGINAL_SOURCE_FIELD",
}},
],
{
multi: true,
upsert: false,
}
);
db.test1.update(
{
"filter_field": 1,
},
[
{$set: {
"target_field": "$source_field"
}}
]
);
{$cond: {
if: {$eq: [ {$ifNull: ["$FIELD_NAME", null]}, null ]},
then: NumberInt(0),
else: NumberInt(1)
}},