Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

GRANT PRIVILEGE TO ROLE grants an additional privilege or inherited role to an existing role in the current database.
This is equivalent to the grantPrivilegesToRole command (http://docs.mongodb.org/manual/reference/command/grantPrivilegesToRole/)

Example


Code Block
GRANT PRIVILEGE DB mydatabase COLLECTION mycollection ACTIONS "find" TO ROLE comrole

Example


Code Block
GRANT PRIVILEGE DB sports COLLECTION test ACTIONS "find", "insert", "remove", "update" TO ROLE all_baseball_role

Example




Code Block
GRANT PRIVILEGE DB "admin" COLLECTION "baseball" Actions "createCollection","createIndex","createRole","createUser","dropCollection"
TO ROLE "test_deployment"

...



Back to top

GRANT ROLE TO ROLE

...

GRANT ROLE TO ROLE grants an additional role or inherited role to an existing role in the current database.
This is equivalent to the grantRolesToRole command (http://docs.mongodb.org/manual/reference/command/grantRolesToRole/)

Example


Code Block
GRANT ROLE newrole DB mydatabase TO ROLE comrole


Back to top

REVOKE PRIVILEGE FROM ROLE

...

REVOKE PRIVILEGE FROM ROLE revokes a privilege or inherited role from an existing role in the current database.
This is equivalent to the revokePrivilegesFromRole command (http://docs.mongodb.org/manual/reference/command/revokePrivilegesFromRole/)

Example



Code Block
REVOKE PRIVILEGE DB mydatabase COLLECTION mycollection ACTIONS "find" FROM ROLE comrole

Example



Code Block
REVOKE PRIVILEGE DB sports COLLECTION test ACTIONS "insert", "remove", "update" FROM ROLE all_baseball_role

Example



Code Block
REVOKE PRIVILEGE DB "user" COLLECTION "user" ACTIONS "dropCollection","dropRole","dropUser","emptycapped","enableProfiler"
FROM ROLE "test_deployment"


Back to top

REVOKE ROLE FROM ROLE

...

REVOKE ROLE FROM ROLE revokes a role or inherited role from an existing role in the current database.
This is equivalent to the revokeRolesFromRole command (http://docs.mongodb.org/manual/reference/command/revokeRolesFromRole/)

Example


Code Block
REVOKE ROLE newrole DB mydatabase FROM ROLE comrole


Back to top

Supported Functions

...

SUM

Sums the values.

Example


Code Block
SELECT city, SUM(pop) FROM zips GROUP BY city


Back to top

Arithmetic and Mathematical Functions

...

Multiplies one or more numbers and returns their product.

Example



Code Block
SELECT itemID + prodID
    FROM products
    WHERE dodad='whirlygig4'


Operators from the Aggregation Framework have some limitations. For example, given the baseball collection containing documents like:

{ "teamName" : "Cardinals",
  "city" : "St. Louis",

  "division" : "NL Central",
  "ranking" : 1,
  "managerName" : { "first" : "Mike", "last" : "Matheny" },
  "colors" : [ "red", "white" ],

  "worldChampionships" : 11,
  "stats" : [ { "year" : 2010, "wins" : 86, "losses" : 76, "winPercentage" : 0.531 },
             
{ "year" : 2011, "wins" : 90, "losses" : 72, "winPercentage" : 0.556 },
             
{ "year" : 2012, "wins" : 88, "losses" : 74, "winPercentage" : 0.543 }
            ]
}


The query:

SELECT stats.wins + stats.losses FROM baseball

will translate to

db.baseball.aggregate({$project: { "sum": { $add: ["$stats.wins", "$stats.losses"] } } })

which will throw an exception:

"exception: Exception occurred during aggregation: exception: can't convert from BSON type Array to double "

as the aggregation operator cannot work inside arrays.





Back to top

Bit Functions

Bit Functions perform bit manipulations between two expressions of any of the integer data type.

...