Home
Abdessamad MOUHASSINE edited this page Jun 15, 2016
·
2 revisions
Vitamin provides a simple and easy to use ActiveRecord implementation for working with your database. It supports Postgres, MySQL, MariaDB, SQLite3, and Oracle databases, featuring both promise based and traditional callback interfaces, providing lazy and eager relationships loading, life-cycle events, default attributes, mass assignment protection, and more.
$ npm install --save vitamin
Then install one of the supported database drivers
$ npm install pg
$ npm install sqlite3
$ npm install mysql
$ npm install mysql2
$ npm install mariasql
$ npm install strong-oracle
$ npm install oracle
The database connection is initialized by passing a config object to model's static method connection
var Model = require('vitamin/model')
// An example of config object for MySQL which will be used by knex
Model.connection({
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test',
charset : 'utf8'
}
})
The knex documentation provides other examples for different databases.