i have an embedded array of tweets in my Mongodb and with every tweet comes a tweetID (not to be confused with the mongodb assigned id).
{
"_id": {
"$oid": "54d95cb062917897ad26c5e5"
},
"name": "foo",
"tweets": [
{
"tweetID": "1234",
"text": "bla bla bla"
},
{
"tweetID": "4321",
"text": "bla bla bla",
}
... and so on
Now in my app I have another array full of tweetID's that should be deleted.
var tweetsToBeDeleted = [ "1234", "4321" ];
And i am trying to get mongoose to do so with:
ChannelsModel.update( { },
{ $pull: { tweets: { $elemMatch: { tweetID: tweetsToBeDeleted } } } },
{ multi: true },
function ( err ) {
console.log( "err - " + err );
}
);
But when i try to run this, nothing gets deleted. The error callback will executed but err is null.
Any ideas?
Thanks in advance!