Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a '.' in your key name in MongoDB (PyMongo)

When I try saving a dict with a '.' in the key PyMongo throws an error (InvaildName) however I do see (on the Mongodb website) that keys can have '.''s in them. Why is it that pymongo won't let me save these docs? Is there an issue with them and Mongo?

James

like image 352
user319723 Avatar asked Apr 23 '10 21:04

user319723


2 Answers

Where are you seeing an example of documents with "." in a key name? Those are invalid in MongoDB (hence PyMongo's restriction).

The reasoning is that we use dot notation in queries to reach inside of embedded documents.

like image 166
mdirolf Avatar answered Oct 23 '22 16:10

mdirolf


You can use the dot in updates and finds, but not in save/insert.

like image 44
eckberg Avatar answered Oct 23 '22 16:10

eckberg