What javascript version do the mongodb shell support?

484 views
Skip to first unread message

wangzx

unread,
Mar 1, 2012, 10:18:23 PM3/1/12
to mongodb-user
It looks that MDN(Mozilla Developer Network) has javascript 1.8,
1.8.1, .. 1.8.5 version, and the new version provide new functions and
new language features.

But it looks that the shell dont support features in 1.8 version ,such
f = function(x) x*x

So what javascript version is supported in the engine? and is there a
way to change 1.8 version support?

PHeinze

unread,
Mar 2, 2012, 6:08:29 AM3/2/12
to mongod...@googlegroups.com
From what I've found it was previously JavaScript Shell based upon SpiderMonkey (which supports JS 1.8.5). But from this ticket https://jira.mongodb.org/browse/SERVER-2407 it was switched to V8,the one from google. And V8 supports only ECMAScript v5 (http://code.google.com/p/v8/).
I'm not sure about supporting JS 1.8+, but I highly doubt that you can easily get it supported. One way would be to change the JS interpreter, which will not happen again (soon). Or maybe V8 itself gets JS 1.8 support then mongodb would only need to use this new version.

As I'm no dev that's still something like speculation and the last word lays at 10gen. Do you really need those new features, or is it just for convience?
Something you shouldn't really do is to throw { & } away just for lazyness thats evil for all kind of switch statements (if, else) and isn't better for functions, you can do this: f = function(x) { return x*x} which will work, and should be what you want.

Eliot Horowitz

unread,
Mar 2, 2012, 7:53:20 AM3/2/12
to mongod...@googlegroups.com
it is currently based off of spidermonkey 1.7.
We have not switched to spidermonkey 1.8.5 or v8 due to
incompatibilities at this point.

> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mongodb-user/-/Hg0xQ4kYf-gJ.
>
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.

wangzx

unread,
Mar 2, 2012, 10:12:22 AM3/2/12
to mongodb-user
Oh, I just wander if we can build a more native Query Language on
Mongodb, such as

db.things.find( function() name == 'hello' ) (not the same as
current, it will translate to db.thing.find( { name: 'hello'} ) and
executed on the server

So if we can using the 1.8 syntax, It would be more friendly.

On Mar 2, 7:08 pm, PHeinze <philn...@gmail.com> wrote:
> From what I've found it was previously JavaScript Shell based upon
> SpiderMonkey (which supports JS 1.8.5). But from this tickethttps://jira.mongodb.org/browse/SERVER-2407it was switched to V8,the one
Reply all
Reply to author
Forward
0 new messages