Connecting to DB
Alexey Gordeyev edited this page Apr 9, 2015
·
17 revisions
First, we need to define a connection.
For MySQL database need install mysql client. Then:
$ npm install mysql -g
var caminte = require('caminte'),
Schema = caminte.Schema,
db = {
driver : "mysql",
host : "localhost",
port : "3306",
username : "test",
password : "test",
database : "test"
pool : true // optional for use pool directly
};
var schema = new Schema(db.driver, db);
For Redis database need install redis client. Then:
$ npm install redis -g
var caminte = require('caminte'),
Schema = caminte.Schema,
db = {
driver : "redis",
host : "localhost",
port : "6379"
};
var schema = new Schema(db.driver, db);
For SQLite database need install sqlite3 client. Then:
$ npm install sqlite3 -g
var caminte = require('caminte'),
Schema = caminte.Schema,
db = {
driver : "sqlite3",
database : "/db/mySite.db"
};
var schema = new Schema(db.driver, db);