This feature is part of spludo since 1.1.
To configure a database connection within spludo, you need to add such block to
your local.config.js:
config.setPathValue(["database_connections", "default"], {
"driver_name": "MysqlDatabaseDriver",
"driver_options": {
"user": "myusername",
"password": "thisisnopassword",
"database": "mydatabase",
"host": "localhost",
"port": 3306
}
});
All possible driver_options depend on the database driver you use, see the
Api Documentation for MysqlDatabaseDriver for reference of the mysql database
driver.
Now you are able to access the database (e.g. "default") by using the following call:
var database = database_manager.getDatabase('default');
database.selectTableRows('users', 'id = ?', [2])(function(error, results) {
console.log('Fetched user with id 2!', results[0]);
});
If you want to work with the databases please take a look at spludo's service
architecture and make use of the spludo-gen service task!