API Reference
waterline
Datastore-agnostic ORM used by Sails.js that maps models to adapters such as Postgres, MySQL, and MongoDB.
Official Documentation ↗CompatibilityThis documentation covers version
v0.15. Check the official docs for the latest API surface.Installation
npm
npm install waterlinepnpm
pnpm add waterlineMethods
No methods match this filter.
Overview
waterline is a datastore-agnostic ORM that maps models to adapters such as Postgres, MySQL, and MongoDB, and is used by Sails.js. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
Waterline.start— Initializes the ORM with the adapters and datastores you declare.Model.create— Starts an insert for the model; chain fetch to resolve the created record.Model.find— Returns records matching the where criteria, with optional sort and limit.
Example
const Waterline = require('waterline');
const orm = await Waterline.start({
adapters: { 'sails-postgresql': require('sails-postgresql') },
datastores: { default: { adapter: 'sails-postgresql', url: process.env.DATABASE_URL } },
});
Notes
Behavior varies by adapter, so validate queries against the datastore you actually deploy. create returns a builder until you chain fetch.
Verification
Create a record with fetch and confirm it returns a persisted id, then find it back with a matching where clause.
FAQ
- What is an adapter in Waterline?
- Adapters translate model operations into datastore-specific calls, letting the same model run on different databases.
- How do I define a model?
- Call orm.collection with a Waterline Collection definition that lists attributes, then use it for create, find, update, and destroy.
- Is Waterline tied to Sails.js?
- No. Sails uses it by default, but Waterline can run standalone with the start API as shown here.
Report a problem with this API docOpens a pre-filled issue on GitHub.