{
SomeId: ObjectId('61deed5d550b7a527ddd869e'),
Timestamp: {
$gte: ISODate('2022-09-01T00:00:00.000Z'),
$lte: ISODate('2022-10-01T00:00:00.000Z')
},
SomethingNotNull: {
$ne: null
}
Aggregate Example
{
"collection": "Coll",
"aggregate": [
{
"$lookup": {
"from": "Status",
"localField": "StatusIds",
"foreignField": "_id",
"as": "status"
}
},
{
"$unwind": {
"path": "$status",
"preserveNullAndEmptyArrays": true
}
},
{
"$match": {
"SomeIdCheck": {"$oid": ""},
"status.Name": "pothole_default"
}
},
{
"$group": {
"count": {
"$sum": 1
},
"_id": { "GroupMeBy":"Hello"}
}
}
]
}
Normally DeleteMany() will not delete stuff in CosmosDB, you have to delete documents one by one.
Use the following NodeJS script to do that
const { MongoClient, ObjectId } = require("mongodb");
const uri = "";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db('database');
const items = database.collection('collection');
const query = { MyQueryToDo: new ObjectId("") };
const loadedItems = items.find(query);
const count = await items.countDocuments(query);
console.log("Loading " + count + " items...");
let i = 0;
loadedItems.forEach(item => {
items.deleteOne({_id: item._id });
i++;
if(i % 100 == 0) {
console.log(i);
}
})
} finally {
// Ensures that the client will close when you finish/error
// await client.close();
}
}
run().catch(console.dir);