1.0.0-prod • Published 5 years ago
@samgaia/db v1.0.0-prod
Samgaia Database
Database module for Samgaia applications
Getting Started
Prerequisites
This database module works with Node >= v8.6.0
For this module to work, you need to have process environment
set with this values
DB_HOST=<-- YOUR DB HOST -->
DB_USER=<-- YOUR DB USER -->
DB_PASS=<-- YOUR DB PASSWORD -->
DB_NAME=<-- YOUR DB NAME -->
DB_PREF=<-- YOUR DB PREFIX (if any) -->
Installing
npm install git+https://gitlab.com/samgaia/db.git
Usages
By default its the main database environment used.
- Initializing
import { Database as database } from '@samgaia/db';
async function getUsers() {
const users = await database.select().from('users');
return users;
}
You can use it for another database by calling the class
import { DatabaseClass, IDatabaseConfiguration } from '@samgaia/db';
const options: IDatabaseConfiguration = {
host: 'YOUR_OTHER_DB_HOST',
user: 'YOUR_OTHER_DB_USER',
password: 'YOUR_OTHER_DB_PASS',
database: 'YOUR_OTHER_DB_DATABASE',
};
const database = new DatabaseClass(options).getInstance();
API
For full API see Official Knexjs docs
Authors
- Marvin Slegt - Initial work
See also the list of contributors who participated in this project.
License
This project is private and belong to Samgaia B.V.
Latest version
- 1.0.0-prod
Issues
- Visit issues page
1.0.0-prod
5 years ago