Please I am new in mongo db and I want to delete one item from my list, I tried several approches but it's not working.
{
name: 'ABCDE',
snapshotString: [
'{"timestamp":1589316266621,"testObject":{}, "moreAttributes" : "XXXXX"}',
'{"timestamp":1589316279337,"testObject":{}, "moreAttributes" : "XXXXX"}'
],
snapshots: [
1589316266621,
1589316279337
]
}
I want to delete a snapshotString
for given timestamp I did this:
this.testCase.updateOne(
{name:room, "snapshotString.timestamp": timestamp},
{ $pull: { "snapshotString.timestamp": timestamp } }, { safe: true },
function(err, obj) {
console.log(" ***** err ***** "+err);
});
And it's a way to have one query to delete both documents with timestamp in snapshotString
and snapshots
in the same query?
Thanks