I want to remove all documents with a field not in an array of ids that I have. When I try, it just removes everything from my database.
This is the code I have:
public function removeNotInListingIdList($ids, $country) {
$dm = $this->getDocumentManager();
$dm->createQueryBuilder('DnDReactivePandoraBundle:Property')
->remove()
->field('listingId')->notIn($ids)
->field('country', $country)
->getQuery()
->execute();
}
What I'm I doing wrong here?
UPDATE
This is the output of the debug instruction:
Array
(
[type] => 3
[query] => Array
(
[listingId] => Array
(
[$nin] => Array
(
[0] => 15-77
[1] => 15-79
[2] => 15-82
[3] => 13-39
[4] => 15-85
[5] => 15-86
[6] => 15-60
[7] => 15-61
[8] => 16-8
)
)
[country] => Mexico
)
[newObj] => Array
(
)
)