# waterline-models

> Auto loads waterline models from a directory

Latest version **0.3.1** (published 2017-06-01) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install waterline-models
pnpm add waterline-models
yarn add waterline-models
bun add waterline-models
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2017-06-01 |
| First published | 2015-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | ksmithut |
| Maintainers | ksmithut |
| Keywords | waterline, model, loader |

## Links

- npm: https://www.npmjs.com/package/waterline-models
- Repository: https://github.com/ksmithut/waterline-models
- Issues: https://github.com/ksmithut/waterline-models/issues
- npm.io page: https://npm.io/package/waterline-models

## Dependencies (3)

- [bluebird](https://npm.io/package/bluebird.md) ^3.5.0
- [waterline](https://npm.io/package/waterline.md) ^0.11.11
- [require-dir](https://npm.io/package/require-dir.md) ^0.3.0

## Recent versions

- 0.3.1 (latest) — 2017-06-01
- 0.3.0 — 2015-08-19
- 0.2.0 — 2015-07-16
- 0.1.0 — 2015-07-16

## README

# waterline-models

[![NPM version](http://img.shields.io/npm/v/waterline-models.svg?style=flat)](https://www.npmjs.org/package/waterline-models)
[![Dependency Status](http://img.shields.io/david/ksmithut/waterline-models.svg?style=flat)](https://david-dm.org/ksmithut/waterline-models)
[![Dev Dependency Status](http://img.shields.io/david/dev/ksmithut/waterline-models.svg?style=flat)](https://david-dm.org/ksmithut/waterline-models#info=devDependencies&view=table)
[![Code Climate](http://img.shields.io/codeclimate/github/ksmithut/waterline-models.svg?style=flat)](https://codeclimate.com/github/ksmithut/waterline-models)
[![Build Status](http://img.shields.io/travis/ksmithut/waterline-models/master.svg?style=flat)](https://travis-ci.org/ksmithut/waterline-models)
[![Coverage Status](http://img.shields.io/codeclimate/coverage/github/ksmithut/waterline-models.svg?style=flat)](https://codeclimate.com/github/ksmithut/waterline-models)

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

```bash
npm install --save waterline-models
```

# Usage

`models/user.js`

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

`app.js`

```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](https://github.com/balderdashy/waterline-docs/blob/master/introduction/getting-started.md).

---
_Source: https://npm.io/package/waterline-models · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
