[DOCS-1595] Table listing JS equivalents of non-JS shell helpers Created: 10/Jun/13  Updated: 30/Oct/23  Resolved: 09/Jul/13

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Stennie Steneker (Inactive) Assignee: Allison Reinheimer Moore
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-6237 Shell helpers should document the ana... Backlog
Participants:
Days since reply: 10 years, 32 weeks, 1 day ago

 Description   

The documentation page on Write Scripts for the mongo Shell mentions that you cannot include use <dbname> inside a JavaScript file, but does not have a full list of equivalent JS for other interactive helpers such as "show dbs".

We should include a table mapping these, for example:

Shell helper JavaScript equivalent
show dbs db.adminCommand('listDatabases')
show collections db.getCollectionNames()
show users db.system.users.find()
show log <logname> db.adminCommand( {'getLog': '<logname>'}

)

use <db_name> db.getSiblingDB('<db_name>')

It is also worth noting that in non-interactive mode (i.e. --eval) these commands will return the corresponding JavaScript data, but will not display any output. The printjson() function can be used to display the results of a JavaScript function, for example: printjson(db.adminCommand('listDatabases')).

This should probably also be cross-referenced from Running .js files via a mongo shell Instance on the Server.



 Comments   
Comment by auto [ 09/Jul/13 ]

Author:

{u'username': u'schmalliso', u'name': u'schmalliso', u'email': u'allison.moore@10gen.com'}

Message: DOCS-1595 adding table mapping helpers to their javascript equivalents

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/5a7415d401ab1e7c50e9f7aeddc8473b2afc6b88

Comment by auto [ 09/Jul/13 ]

Author:

{u'username': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: DOCS-1595: syntax fixes
Branch: master
https://github.com/mongodb/docs/commit/fd8a46a389db5dc3b3ae607eced038d82292f54b

Comment by auto [ 09/Jul/13 ]

Author:

{u'username': u'schmalliso', u'name': u'schmalliso', u'email': u'allison.moore@10gen.com'}

Message: DOCS-1595 adding table mapping helpers to their javascript equivalents

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/3f8bc03777cdffd35f4827e940cefac863e77672

Generated at Thu Feb 08 07:41:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.