Paste the date document into the collection in Robomongo

I work with Robomongo, where I manually insert an object.

I want my object to have a field that is the current date. I usually use Date.now() in Javascript. However, when I use the insert form in the Robomongo tool, I get:

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

JSON example:

 { serial: '1231323123', game: 'World of Warcraft', date: Date.now() } 

Any idea how to insert this entry?

+7
mongodb robo3t
source share
2 answers

Unfortunately, at this stage this cannot be done, as indicated in the next github release:

https://github.com/paralect/robomongo/issues/477

... there are several differences between the Robomongo JavaScript engine and the v8 engine, which is used by default in mongo shell 2.4+.


Problem No. 520 should fix the problem by updating the built-in shell that ships with Robomongo from SpiderMonkey to v8 (the default is MongoDB 2.4+).

+3
source share

Your example works fine if you insert it directly into the Robomongo 0.8.4 shell tooltip, for example, in the game collection:

 db.game.insert({ serial: '1231323123', game: 'World of Warcraft', date: Date.now() }) 

If you use the context menu ( Insert Document... ), the JSON parser will return a syntax error that you encounter.

The problem here is that JSON checking is currently being done using a library that is not MongoDB specific. The above is not valid JSON for several reasons (unspecified keys and value without quotes), but it is valid for insertion into the mongo shell.

I created Robomongo issue # 619 for this. The related JSON check difference is issue number 448 .

Until the JSON validation error is fixed, I would suggest inserting documents like this on the command line in Robomongo.

+4
source share

All Articles