-
Notifications
You must be signed in to change notification settings - Fork 23
Database
develephant edited this page Feb 4, 2016
·
2 revisions
You will need a Mongo database connection object for these methods. See Connection.
Methods:
List the collections for the currently selected database.
Parameters
None
Returns
A table array of collections, or nil.
local collections = db:list()
for _, collection in ipairs( collections ) do
print( collection.name )
end
Get a collection reference from the database.
Parameters
Name | Description | Default | Required |
---|---|---|---|
collection_name | A string name of the collection | none | Yes |
Returns
A collection object, or nil.
local collection = db:get_col( collection_name )
Adds a database User for authentication.
Parameters
Name | Description | Default | Required |
---|---|---|---|
username | A string name for the database User | none | Yes |
password | A string password for the database User | none | Yes |
Returns
On success returns 1, or nil and error message.
local ok, err = db:add_user( username, password )
Authenticates a User with the database.
Parameters
Name | Description | Default | Required |
---|---|---|---|
username | A string name for the database User | none | Yes |
password | A string password for the database User | none | Yes |
Returns
On success returns 1, or nil and error message.
local ok, err = db:auth( username, password )
Usage unknown.
Parameters
Name | Description | Default | Required |
---|---|---|---|
fs | Usage unknown | ? | ? |
Returns
A gridfs object.
local gridfs = db:get_gridfs( fs )
Removes the selected database, and all related collections.
Parameters
None
Returns
Nothing
db:dropDatabase()