Skip to content

JerrySievert/depeche

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Depeche

Fast models.

This is a package used for my personal projects. It has grown over time, and it made sense to release it as a module.

Usage

$ npm install --save depeche

file.js:

var Depeche = require('depeche');

function Model ( ) {
  this._table = 'model';
  this._primary = 'id';
  this._fields = [
    'id',
    'some_field',
    'some_other_field',
    'created_date'
  ];

  Depeche.model.extend(this, Model);
}

var model = new Model();

Configuration

Configuration occurs once, and is used for all database activity after configuration.

var Depeche = require('depeche');

Depeche.db.config({
  username: 'username',
  password: 'password',
  hostname: 'hostname',
  password: 'password'
});

Insert

var model = new Model();

model.some_field = 'Hello';
model.some_other_fields = 'World';

model.insert(function results (err, rows) {
  console.log("Inserted " + rows.length);
});

Query

var model = new Model();

model.where('some_field').eq('Hello');

model.all(function (err, rows) {
  console.log("Found " + rows.length);
});

About

My own personal models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published