This feature is part of spludo since 1.1.

A database driver is just a class which implements the following interface. See MysqlDatabaseDriver (Api Documentation for MysqlDatabaseDriver) as reference.

One could use a database driver like this:

database.query(sql, parameters_array)(function(error, results) {
    // error is true or false
    // results depends on the query
});
database.createTableRow(table_name, values)(function(error, last_insert_id) {
    // error is true or false
    // last_insert_id is the id of the last itemamount of removed rows
});
database.selectTableRows(table_name, where_condition, where_parameters_array)(function(error, results) {
    // error is true or false
    // results is an array of rows
});
database.updateTableRows(table_name, values, where_condition, where_parameters_array)(function(error, affected_rows_count) {
    // error is true or false
    // affected_rows_count is the amount of updated rows
});
database.deleteTableRows(table_name, where_condition, where_parameters_array)(function(error, affected_rows_count) {
    // error is true or false
    // affected_rows_count is the amount of removed rows
});

For DatabaseMigration-purpose there are also some methods like database#createTable. Please have a look at the Api Documentation for MysqlDatabaseDriver for reference.

Comments