4

Many years ago we launched a project to manage semi-structured information for research projects. We used CouchDB, and at that time it was convenient for us to call the mandatory fields of entries starting with a dollar sign ($) {"id": 123, "$type": "entry", "$owners": ["somebody"],... } I have to clarify that Mango did not exist for CouchDB at that time. Now I would like to run the query to find all the entries of my database which "$type" is "entry". But Mango throws an error because "$type" is not an operator.

{"$type": "entry"}

Does somebody know a way to circumvent this problem that does not require to fix the names on my database?

Is there a way to escape the dollar sign in the names?

2 Answers2

4

As mentioned in this duplicate question, as well as on this CouchDB GitHub issue, this is possible by escaping the $ character:

... you can escape the dollar sign with \\$keyname.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
0

From the github issue, I got this answer, and I confirm it works.

Looks like you can escape the dollar sign with \\$keyname.

In my case, {"\\$type": "entry"}

derloopkat
  • 6,232
  • 16
  • 38
  • 45