Class luchia.database
High-level database class.
Contains all of the high-level methods to manage databases. This module should be used instead of the core modules when possible.
See the database.lua example for more detail.
Info:
- Copyright: 2011-2015 Chad Phillips
- Author: Chad Phillips
Local Functions
luchia.database.database_call(self, method, database_name) | Make a database-related request to the server. |
Methods
luchia.database:new(self, server_params) | Create a new database handler object. |
luchia.database:list() | List all databases. |
luchia.database:info(database_name) | Get information on a database. |
luchia.database:create(database_name) | Create a database. |
luchia.database:delete(database_name) | Delete a database. |
luchia.database:response_ok(response) | Check the response for success. |
Local Functions
Methods- luchia.database.database_call(self, method, database_name)
-
Make a database-related request to the server.
Parameters:
- self
- method Required. The HTTP method.
- database_name Required. The database name.
Returns:
-
The following four values, in this order: responsedata,
responsecode, headers, status_code.
Methods
- luchia.database:new(self, server_params)
-
Create a new database handler object.
Parameters:
- self
- server_params
Optional. A table of server connection parameters (identical to
default.server
in luchia.conf. If not provided, a server object will be generated from the default server configuration.
Returns:
-
A database handler object.
Usage:
db = luchia.database:new(server_params)
- luchia.database:list()
-
List all databases.
Returns:
-
Same values as database_call, response_data is a list of databases.
See also:
Usage:
db:list()
- luchia.database:info(database_name)
-
Get information on a database.
Parameters:
- database_name Required. The database to get info from.
Returns:
-
Same values as database_call, response_data is a table of database
information.
See also:
Usage:
db:info("example_database")
- luchia.database:create(database_name)
-
Create a database.
Parameters:
- database_name Required. The database to create.
Returns:
-
Same values as database_call, response_data is a table of the
request result.
See also:
Usage:
db:create("example_database")
- luchia.database:delete(database_name)
-
Delete a database.
Parameters:
- database_name Required. The database to delete.
Returns:
-
Same values as database_call, response_data is a table of the
request result.
See also:
Usage:
db:delete("example_database")
- luchia.database:response_ok(response)
-
Check the response for success.
A convenience method to ensure a successful request.
Parameters:
- response Required. The response object returned from the server request.
Returns:
-
true if the server responsed with an ok:true, false otherwise.
Usage:
operation_succeeded = db:response_ok(response)