!e.eoo() error in MongoDB query
Question
Something is wrong with this query, and I can't tell what it is. I am sure it's something very simple:
db.foo.insert({
'created at': new Date(),
ooc: false,
body: '<p>Moo</p>\n',
keywords: [ 'Moo' ],
mentioned: [],
tags: [],
sender: {
_id: 'stuff',
name: 'lambdadusk',
'display name': 'Lambda'
}
});
The error I get from Mongo is simply
!e.eoo()
I'm using MongoDB 2.0.5. Googling the error did not tell me much.
Solution
I should have tried that earlier.
The problem is not the query, but the BSON datafile of the collection was corrupted somehow. I had to drop the collection, then re-try.
Luckily, the collection was empty as I am early in development.
OTHER TIPS
eoo means end-of-object and if it's not there, you may well have a parse error in your JSON. Possibly Mongo wants strictly valid JSON, so you may need to use double quotes for all strings and maybe remove the new Date() bit.
http://jsonlint.com/ suggested that this would be valid, whereas the code you posted isn't. Not sure if that'll help or not as Mongo uses BSON, so may be more flexible.
{
"created at": {},
"ooc": false,
"body": "<p>Moo</p>\n",
"keywords": [
"Moo"
],
"mentioned": [],
"tags": [],
"sender": {
"_id": "stuff",
"name": "lambdadusk",
"displayname": "Lambda"
}
}