This package has been deprecated

Author message:

This module is no longer being maintained. Please reach out to package author if you wish to take over maintenance.

waterline-models

0.3.1 • Public • Published

waterline-models

NPM version Dependency Status Dev Dependency Status Code Climate Build Status Coverage Status

Auto loads waterline models from a directory

Looking for another maintainer. I no longer use waterline and would like to have someone else take over. If you are interested, please reach out. Otherwise, eventually I will have this package removed. I doubt this module is used enough for people to read this, but in case it is read, there's your notice.

Installation

npm install --save waterline-models

Usage

models/user.js

module.exports = {
  identity: 'user',
  connection: 'default',
  attributes: {
    firstName: 'string',
    lastName: 'string'
  }
};

app.js

var path = require('path');
var waterlineModels = require('waterline-models');
waterlineModels.init({
  dir: path.join(__dirname, 'models'),
  adapters: {
    memory: require('sails-memory-adapter')
  },
  connections: {
    default: {
      adapter: 'memory'
    }
  }
});
 
// This could be in another file
var User = require('waterline-models')('user'); // pass in the identity
 
User
  .then(function (Model) {
    return Model.create({
      firstName: 'Jack',
      lastName: 'Bliss'
    });
  })
  .then(function (user) {
    console.log(user);
    // {
    //   firstName: 'Jack',
    //   lastName: 'Bliss',
    //   createdAt: Some Date,
    //   updatedAt: Some Date,
    //   id: 1
    // }
  });

Options

cwd

The cwd directory to work off of when reading from the models directory

Default: process.cwd()

dir

The path to your models directory

Default: 'models'

defaultCollection

All other options are passed into waterline's initialize method as the configuration which is documented here.

Readme

Keywords

Package Sidebar

Install

npm i waterline-models

Weekly Downloads

1

Version

0.3.1

License

MIT

Last publish

Collaborators

  • ksmithut