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 Waterline documentation.
Looking for the version of Waterline used in Sails v0.12? See https://github.com/balderdashy/waterline/tree/0.11.x.
Install from NPM.
$ npm install waterline
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.
It also allows an adapter to define its own methods that don't necessarily fit into the CRUD methods defined by default in Waterline. If an adapter defines a custom method, Waterline will simply pass the function arguments down to the adapter.
- PostgreSQL - 0.9+ compatible
- MySQL - 0.9+ compatible
- MongoDB - 0.9+ compatible
- Memory - 0.9+ compatible
- Disk - 0.9+ compatible
- Microsoft SQL Server
- Apache Cassandra
- Apache Derby
Need help or have a question? Click here.
To report a bug, click here.
Please observe the guidelines and conventions laid out in our contribution guide when opening issues or submitting pull requests.
$ npm test
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:
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.)
|fetch||false||For adapters: When performing
Related model settings
To provide per-model/orm-wide defaults for the
fetch meta keys, there are a few different model settings you might take advantage of:
attributes: ...primaryKey: 'id'cascadeOnDestroy: truefetchRecordsOnUpdate: truefetchRecordsOnDestroy: 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.
Rough draft of documentation for a few new methods available in Waterline v0.13.
Replace the specified collection of one or more parent records with a new set of members.
// For users 3 and 4, change their "pets" collection to contain ONLY pets 99 and 98.User;
Under the covers, what this method actually does varies depending on whether the association passed in uses a junction or not.
We know a plural association must use a junction if either (A) it is one-way ("via-less") or (B) it reciprocates another plural association.
If the association uses a junction, then any formerly-ascribed junction records are deleted, and junction records are created for the new members. Otherwise, if the association doesn't use a junction, then the value of the reciprocal association in former child records is set to
null, and the same value in newly-ascribed child records is set to the parent record's ID. (Note that, with this second category of association, there can only ever be one parent record. Attempting to pass in multiple parent records will result in an error.)
Add new members to the specified collection of one or more parent records.
// For users 3 and 4, add pets 99 and 98 to the "pets" collection.// > (if either user record already has one of those pets in its "pets",// > then we just silently skip over it)User;
Remove members from the the specified collection of one or more parent records.
// For users 3 and 4, remove pets 99 and 98 from their "pets" collection.// > (if either user record does not actually have one of those pets in its "pets",// > then we just silently skip over it)User;
MIT. Copyright © 2012-2016 Balderdash Design Co.