New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

waterline

Package Overview
Dependencies
Maintainers
4
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

waterline

An ORM for Node.js and the Sails framework

  • 0.13.0-rc1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
decreased by-23.34%
Maintainers
4
Weekly downloads
 
Created
Source

Waterline logo

NPM version Master Branch Build Status Master Branch Build Status (Windows) StackOverflow (waterline) StackOverflow (sails)

Waterline is a brand new kind of storage and retrieval engine.

It provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. That means you write the same code to get and store things like users, whether they live in Redis, MySQL, MongoDB, or Postgres.

Waterline strives to inherit the best parts of ORMs like ActiveRecord, Hibernate, and Mongoose, but with a fresh perspective and emphasis on modularity, testability, and consistency across adapters.

For detailed documentation, see the Sails documentation.

Looking for the version of Waterline used in Sails v0.12? See https://github.com/balderdashy/waterline/tree/0.11.x.

Installation

Install from NPM.

  $ npm install waterline

Overview

Waterline uses the concept of an adapter to translate a predefined set of methods into a query that can be understood by your data store. Adapters allow you to use various datastores such as MySQL, PostgreSQL, MongoDB, Redis, etc. and have a clear API for working with your model data.

Waterline supports a wide variety of adapters both core and community maintained.

Help

Need help or have a question? Click here.

Bugs   NPM version

To report a bug, click here.

Contribute

Please observe the guidelines and conventions laid out in our contribution guide when opening issues or submitting pull requests.

Tests

All tests are written with mocha and should be run with npm:

  $ npm test

Meta Keys

As of Waterline 0.13 (Sails v1.0), these keys allow end users to modify the behaviour of Waterline methods. You can pass them as the meta query key, or via the .meta() query modifier method:

SomeModel.create({...})
.meta({
  skipAllLifecycleCallbacks: true
})
.exec(...);

These keys are not set in stone, and may still change prior to release. (They're posted here now as a way to gather feedback and suggestions.)

Meta KeyDefaultPurpose
cascadefalseSet to true to automatically "empty out" (i.e. call replaceCollection(..., ..., [])) on plural ("collection") associations when deleting a record. Note: In order to do this when the fetch meta key IS NOT enabled (which it is NOT by default), Waterline must do an extra .find().select('id') before actually performing the .destroy() in order to get the IDs of the records that would be destroyed.
fetchfalseFor adapters: When performing .update() or .create(), set this to true to tell the database adapter to send back all records that were updated/destroyed. Otherwise, the second argument to the .exec() callback is undefined. Warning: Enabling this key may cause performance issues for update/destroy queries that affect large numbers of records.
skipAllLifecycleCallbacksfalseSet to true to prevent lifecycle callbacks from running in the query.
skipRecordVerificationfalseSet to true to skip Waterline's post-query verification pass of any records returned from the adapter(s). Useful for tools like sails-hook-orm's automigrations. Warning: Enabling this flag causes Waterline to ignore customToJSON!
skipExpandingDefaultSelectClausefalseSet to true to force Waterline to skip expanding the select clause in criteria when it forges stage 3 queries (i.e. the queries that get passed in to adapter methods). Normally, if a model declares schema: true, then the S3Q select clause is expanded to an array of column names, even if the S2Q had factory default select/omit clauses (which is also what it would have if no explicit select or omit clauses were included in the original S1Q.) Useful for tools like sails-hook-orm's automigrations, where you want temporary access to properties that aren't necessarily in the current set of attribute definitions. Warning: Do not use this flag in your web application backend-- or at least ask for help first.

To provide per-model/orm-wide defaults for the cascade or fetch meta keys, there are a few different model settings you might take advantage of:

{
  attributes: {...},
  primaryKey: 'id',

  cascadeOnDestroy: true,

  fetchRecordsOnUpdate: true,
  fetchRecordsOnDestroy: true,
  fetchRecordsOnCreate: true,
  fetchRecordsOnCreateEach: true,
}

Not every meta key will necessarily have a model setting that controls it-- in fact, to minimize peak configuration complexity, most will probably not.

License

MIT. Copyright © 2012-2017 Mike McNeil, Balderdash Design Co., & The Sails Company

Waterline, like the rest of the Sails framework, is free and open-source under the MIT License.

image_squidhome@2x.png

Keywords

FAQs

Package last updated on 16 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc