| Class | Mongo::Auth::User::View |
| In: |
lib/mongo/auth/user/view.rb
|
| Parent: | Object |
Defines behavior for user related operation on databases.
@since 2.0.0
| database | [R] | @return [ Database ] database The view‘s database. |
Initialize the new user view.
@example Initialize the user view.
View::User.new(database)
@param [ Mongo::Database ] database The database the view is for.
@since 2.0.0
Create a new user in the database.
@example Create a new read/write user.
view.create('user', password: 'password', roles: [ 'readWrite' ])
@param [ Auth::User, String ] user_or_name The user object or user name. @param [ Hash ] options The user options.
@option options [ Session ] :session The session to use for the operation.
@return [ Result ] The command response.
@since 2.0.0
Get info for a particular user in the database.
@example Get a particular user‘s info.
view.info('emily')
@param [ String ] name The user name. @param [ Hash ] options The options for the info operation.
@option options [ Session ] :session The session to use for the operation.
@return [ Hash ] A document containing information on a particular user.
@since 2.1.0
Remove a user from the database.
@example Remove the user from the database.
view.remove('user')
@param [ String ] name The user name. @param [ Hash ] options The options for the remove operation.
@option options [ Session ] :session The session to use for the operation.
@return [ Result ] The command response.
@since 2.0.0
Update a user in the database.
@example Update a user.
view.update('name', password: 'testpwd')
@param [ Auth::User, String ] user_or_name The user object or user name. @param [ Hash ] options The user options.
@option options [ Session ] :session The session to use for the operation.
@return [ Result ] The response.
@since 2.0.0