Need to see if we can generate js script instead of sql script for the following action items under MongoJS:
Script Database CREATE
Script Database DROP
Script Collection.Field ALTER
Script Collection.Field DROP
Script Index CREATE
Script Index CREATE (Full)
Script Index DROP
Script Role CREATE
Script User CREATE
Script User DROP
![]() |
8 KB
|
100 KB
@ambikesh: pls provide the MongoJS equivalent syntax for all these commands. See linked issue #13868 for context.
@Sachin,
Please refer the attachment : MongoJSCommand.docx
@Sachin,
Please refer the attachment : MongoJSCommand.docx
Available in ADS 18.0.0-dev-51:
- Script Index CREATE
- Script Index CREATE (Full)
- Script Index DROP
- multi-select Script Index
- Script Collection CREATE (Full) also scripts indexes in MongoJS
Available in ADS 18.0.0-dev-51:
- Script Index CREATE
- Script Index CREATE (Full)
- Script Index DROP
- multi-select Script Index
- Script Collection CREATE (Full) also scripts indexes in MongoJS
Vasudev, the attached MongoJSCommand.docx document doesn't have the right information for implementation. Refer to my issue comment for more details.
Please research the MongoJS equivalent commands for the following remaining MongoSQL Script actions. Script Index actions in MongoJS have already been implemented.
Vasudev, the attached MongoJSCommand.docx document doesn't have the right information for implementation. Refer to my issue comment for more details.
Please research the MongoJS equivalent commands for the following remaining MongoSQL Script actions. Script Index actions in MongoJS have already been implemented.
- Script Database CREATE
use databaseName
use newDatabase
db.dropDatabase();
use newDatabase db.dropDatabase()
db.collection.update({}, {$rename: { <field1>: <newName1>} );
Example:
db.students.update( { }, { $rename: { "nmae": "name" } } )
db.collection.update({}, {$unset: {'field':""}});
Example:
db.products.update( { }, { $unset: { quantity: "", instock: "" } } )
We can use following command to create role
db.createRole(role, writeConcern)
role document has follwoing format:
{ role: "<name>", privileges: [ { resource: { <resource> }, actions: [ "<action>", ... ] }, ... ], roles: [ { role: "<role>", db: "<database>" } | "<role>", ... ] }
Please refer link for writeConcern.
Example:
use admin db.createRole( { role: "myClusterwideAdmin", privileges: [ { resource: { cluster: true }, actions: [ "addShard" ] }, { resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] }, { resource: { db: "users", collection: "usersCollection" }, actions: [ "update", "insert", "remove" ] }, { resource: { db: "", collection: "" }, actions: [ "find" ] } ], roles: [ { role: "read", db: "admin" } ] }, { w: "majority" , wtimeout: 5000 } )
db.createUser(user, writeConcern);
user document has following format:
{ user: "<name>", pwd: "<cleartext password>", customData: { <any information> }, roles: [ { role: "<role>", db: "<database>" } | "<role>", ... ] }
use products db.createUser( { "user" : "accountAdmin01", "pwd": "cleartext password", "customData" : { employeeId: 12345 }, "roles" : [ { role: "clusterAdmin", db: "admin" }, { role: "readAnyDatabase", db: "admin" }, "readWrite" ] }, { w: "majority" , wtimeout: 5000 } )
db.removeUser("username")
Example:
db.removeUser("user123")
- Script Database CREATE
use databaseName
use newDatabase
db.dropDatabase();
use newDatabase db.dropDatabase()
db.collection.update({}, {$rename: { <field1>: <newName1>} );
Example:
db.students.update( { }, { $rename: { "nmae": "name" } } )
db.collection.update({}, {$unset: {'field':""}});
Example:
db.products.update( { }, { $unset: { quantity: "", instock: "" } } )
We can use following command to create role
db.createRole(role, writeConcern)
role document has follwoing format:
{ role: "<name>", privileges: [ { resource: { <resource> }, actions: [ "<action>", ... ] }, ... ], roles: [ { role: "<role>", db: "<database>" } | "<role>", ... ] }
Please refer link for writeConcern.
Example:
use admin db.createRole( { role: "myClusterwideAdmin", privileges: [ { resource: { cluster: true }, actions: [ "addShard" ] }, { resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] }, { resource: { db: "users", collection: "usersCollection" }, actions: [ "update", "insert", "remove" ] }, { resource: { db: "", collection: "" }, actions: [ "find" ] } ], roles: [ { role: "read", db: "admin" } ] }, { w: "majority" , wtimeout: 5000 } )
db.createUser(user, writeConcern);
user document has following format:
{ user: "<name>", pwd: "<cleartext password>", customData: { <any information> }, roles: [ { role: "<role>", db: "<database>" } | "<role>", ... ] }
use products db.createUser( { "user" : "accountAdmin01", "pwd": "cleartext password", "customData" : { employeeId: 12345 }, "roles" : [ { role: "clusterAdmin", db: "admin" }, { role: "readAnyDatabase", db: "admin" }, "readWrite" ] }, { w: "majority" , wtimeout: 5000 } )
db.removeUser("username")
Example:
db.removeUser("user123")
Support added.Therefore marking this issue as Verified. Tested scripts in devi-162 and devi-163 builds
Support added.Therefore marking this issue as Verified. Tested scripts in devi-162 and devi-163 builds
Verified in ADS 18.0.0-rc-16 in MongoDB 3.4.1
Verified in ADS 18.0.0-rc-16 in MongoDB 3.4.1
Issue #13905 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 18.0.0-devi-161 |
No time estimate |
1 issue link |
relates to #13868
Issue #13868MongoJS -> From Script Object to Window as, SQL scripts are generated instead of MongoJS for Database, Index, Roles,Users and collection fields. |
@ambikesh: pls provide the MongoJS equivalent syntax for all these commands. See linked issue #13868 for context.