How to use dot in field name ?
I see error in example:
db.test2.insert({ "a.a" : "b" }) can't have . in field names [a.a]
Unlike MongoDB, which does not allow dots, ( . ), in JSON or BSON field names, IBM® Informix® conforms to the JSON standard and allows dots. For example: {"user. fn" : "Jake"}. However, you cannot run a query or an operation directly on a field that has a dot in its name.
It's impossible to use a literal dot in a JSON key with FileMaker's JSON parsing functions.
According to the docs, a "$" is reserved for operators. If you look at the group operator however, values need to have a dollar prefixed. These values are not operators.
You can use $getField to retrieve the value of fields with names that contain periods ( . ) or start with dollar signs ( $ ).
You can replace dot symbols of your field name to Unicode equivalent of \uff0E
db.test.insert({"field\uff0ename": "test"}) db.test.find({"field\uff0ename": "test"}).forEach(printjson) { "_id" : ObjectId("5193c053e1cc0fd8a5ea413d"), "field.name" : "test" }
See more:
Actualy you may use dots in queries. See: http://www.mongodb.org/display/DOCS/Dot+Notation+%28Reaching+into+Objects%29
Because of this special dot symbol mean you cannot use it in field names. Like you cannot use dot symbol in identifiers in most of programming languages.
You may write query db.test2.find({ "a.a" : "b" })
but if you want to be able to write such a query you need to insert your object like so: db.test2.insert({"a": {"a": "b"}})
. This will create document with the field named "a"
with the value of embeded document containing the field named "a"
(again) with the value "b"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With