如何在Couchdb芒果中使用以美元符号($)开头的字段名定义_find查询 [英] How to define a _find query in couchdb mango with field names that start with dollar sign ($)
问题描述
许多年前,我们启动了一个项目,以管理研究项目的半结构化信息.我们使用了CouchDB,那时我们可以方便地调用以美元符号($)开头的必填项 {"id":123,"$ type":"entry","$ owners":["somebody"],...} 我必须澄清一下,当时CouchDB不存在Mango.现在,我想运行查询以查找数据库中"$ type"为"entry"的所有条目.但是Mango抛出错误,因为"$ type"不是运算符.
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"}
{"$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?
推荐答案
As mentioned in comments, this is currently not possible, due to an apparent bug in CouchDB:
如果使用语句{"$ type":"entry"}调用_find函数,则芒果会引发错误,因为"$ type"不是运算符.
If you call the _find function with the statement {"$type" : "entry"} Mango throws an error because "$type" is not an operator.
这篇关于如何在Couchdb芒果中使用以美元符号($)开头的字段名定义_find查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!