Waterline ORM
Waterline is the datastore-agnostic ORM/ODM used by Sails.js. It provides a normalized API for interacting with any supported database (PostgreSQL, MySQL, MongoDB, SQLite, Redis) using a consistent query language.
When to Use
Use this skill when:
- Defining Sails.js models (attributes, types, validations, associations)
- Writing Waterline queries (find, create, update, destroy, count, etc.)
- Using criteria objects with operators (
contains,startsWith,in,nin,<,>,!=,or,and) - Setting up associations (one-to-one, one-to-many, many-to-many)
- Handling query errors (
.intercept(),.tolerate(),E_UNIQUE) - Working with transactions, streaming, aggregation, or collection manipulation
- Configuring datastores and model settings
Rules
Read individual rule files for detailed explanations and code examples:
- rules/getting-started.md - Core concepts, model definition, datastores, configuration
- rules/query-language.md - WHERE operators, criteria modifiers, or/and, sort, limit, skip, select, omit
- rules/model-methods.md - find, findOne, findOrCreate, create, update, destroy, and their variants
- rules/associations.md - one-to-one, one-to-many, many-to-many, populate, cross-datastore
- rules/attributes-and-validations.md - Types, validation rules, columnName, protect, encrypt, defaultsTo
- rules/lifecycle-callbacks.md - beforeCreate, beforeUpdate, afterCreate, customToJSON
- rules/error-handling.md - .intercept(), .tolerate(), E_UNIQUE, UsageError, AdapterError
- rules/transactions.md - getDatastore().transaction(), .usingConnection(), leased connections
- rules/aggregation-and-streaming.md - count, sum, avg, stream, eachRecord, eachBatch
- rules/collections-and-advanced.md - addToCollection, removeFromCollection, replaceCollection, archive, native, meta