engined-database
v0.0.1
Published
Database service for engined
Downloads
4
Readme
engined-database
Database agent for engined, used to managing various database backend.
Installation
Install via NPM:
npm install engined-database
Usage
Start engined-database service in engined, see example below:
const { Manager } = require('engined');
const DatabaseService = require('engined-database');
const database = DatabaseService();
const main = async () => {
// Create manager
let serviceManager = new Manager({ verbose: true });
// Adding service to manager
serviceManager.add('Database', database);
// Start all services
await serviceManager.startAll();
};
main();
Using specific database backend
Here is example to get agent for specific backend to save file:
// Using MySQL database backend
let mysqlAgent = this.getContext('Database').getAgent('mysql');
let users = mysqlAgent.model('User').findAll();
Register database backend
// Register agent for customized database backend
this.getContext('Database').registerAgent('mydb', agent);
License
Licensed under the MIT License
Authors
Copyright(c) 2017 Fred Chien(錢逢祥) <[email protected]>