Mongodb – Insert document with date into collection in Robomongo


I am working with Robomongo, where I am manually inserting an object.

I want to have a field on my object, which is the current date. Normally I am used to use in Javascript. However, when I use the insert document form in the Robomongo tool, I get:

Unable to parse JSON:
Expecting '(', at (4, 15).

Sample JSON:

    serial: '1231323123',
    game: 'World of Warcraft',

Any idea how to insert this record?

Best Solution

Your example works fine if you insert it in the Robomongo 0.8.4 shell prompt directly, for example into a game collection:{
    serial: '1231323123',
    game: 'World of Warcraft',

If you use the context menu (Insert Document...), the JSON parser will return the syntax error you are encountering.

The issue here is that the JSON validation is currently done with a library that is not specific to MongoDB. The above is not valid JSON for several reasons (unquoted keys, and the unquoted function value) but is valid to insert in the mongo shell.

I've created Robomongo issue #619 for this. A related JSON validation difference is issue #448.

Until the JSON validation error is fixed, I would suggest inserting documents like this via the shell prompt in Robomongo instead.

Related Question