What characters are NOT allowed in MongoDB field names?

前端 未结 2 414
不知归路
不知归路 2020-11-27 21:14

I figured out that of course . and SPACE aren\'t allowed. Are there other forbidden characters ?

2条回答
  •  不知归路
    2020-11-27 21:25

    Something else to look out for is the fact that you can make a property name called "query" but then use query operators on it, making it awkward to do a large number of queries.

    Example:

    Insert document with a property named

    db.coll.insert({ query: 'foo' });
    

    Equality query works:

    db.coll.findOne({ query: 'foo' });    
    

    Not equal ($ne) does not:

    db.coll.findOne({ query: { $ne: 'bar' } });
    

提交回复
热议问题