I'm a little confused as far as updating a document in mongo is concerned. I'm using API calls with mongoHQ to do so. Say I have the following document:
{
_id: "1234"
}
If I use the API call mentioned here, I am able to successfully update the document with the following PUT body:
{
"document": {
"$set": {
"statistics": {
"http://localhost:8888/": "base"
}
}
}
}
the resulting document is:
{
_id: "1234",
statistics: {
"http://localhost:8888/": "base"
}
}
But if I try doing something like this:
{
"document": {
"$set": {
"statistics": {
"http://localhost:8888/": "base",
"http://localhost:8888/robots.txt": "robots"
}
}
}
}
It refuses to update. Am I missing a key aspect of document updating with mongodb??
Field names cannot contain a period (.
). In the second example, the second URL contains a period (reference): robots.txt
.
You'll need to encode the character before updates. (like a %2E for example).