$ ne generalmente se usa para un valor. Pero si desea excluir varios elementos de la array , puede usar $ nin
Por ejemplo tengo este modelo:
{ "_id": "5a934e000102030405000000", "key": 1 }, { "_id": "5a934e000102030405000001", "key": 2 }, { "_id": "5a934e000102030405000002", "key": 3 }, { "_id": "5a934e000102030405000003", "key": 4 }, { "_id": "5a934e000102030405000004", "key": 5 } Y quiero excluir key:3 y key5 :
db.collection.find({ key: { "$nin": [ 3, 5 ] } })Ahora esta consulta devuelve un resultado correcto:
[ { "_id": "5a934e000102030405000000", "key": 1 }, { "_id": "5a934e000102030405000001", "key": 2 }, { "_id": "5a934e000102030405000003", "key": 4 } ]Espero que esta solución te ayude.