2

I had hunt with this error: node js mongodb remove error "key $lte must not start with '$'", but that did not helped me.

I am doing following query

coll.remove({ _id : { '$ne' :  SomeId }, blah : blaVal });

But that gives the error :

key $ne must not start with '$'

I have started facing this issue, when i migrated mongodb 2.4 to 2.6

My configs are:

nodejs : 0.10
mongodb : 2.6.8 (no issues with 2.4.x)
mongodb driver (npm package version) : 2.1.3 (have tried with 1.4.x and 1.3.x, but error is still there, even emptying node_modules and again `npm install`)

What should I do to resolve the issue?

Community
  • 1
  • 1
codeofnode
  • 18,169
  • 29
  • 85
  • 142
  • In the examples that I see in [this page](https://docs.mongodb.org/manual/reference/operator/query/ne/) they use `$ne` and not `'$ne'`. Not sure if that would change something. Apparently, in the post you are linking to there's already an answer suggesting this. – nbro Jan 11 '16 at 16:57

1 Answers1

1

Keys in mongo are not allowed in Mongo as they are indicating that they are an mongo operator. So if you try to store a Document with a key $ne it will not work.

https://github.com/Automattic/mongoose/issues/1884#issuecomment-1112931805