Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Fast Water

A fastify plugin for waterline. This plugin replicates waterline usage in sails by:

  • Allowing you to define waterline models exactly as in sails
  • Use any sails waterline adapter
  • Gives you access to your models anywhere in the request cycle through the fastify instance


// Setup
const fastWater = require('fast-water')

const options = {
 adapter: require('sails-mysql'),
 adapterType: 'mysql',
 database: {
   name: 'myDb',
   user: 'user',
   password: 'password',
   host: 'localhost'
 decoratorName: 'models',
 modelPath: path.join(__dirname, './models'),
 modelDefaults: {
   datastore: 'default',
   fetchRecordsOnCreate: true,
   fetchRecordsOnUpdate: true,
   primaryKey: 'id',
   attributes: {
     createdAt: { type: 'string', autoCreatedAt: true, },
     updatedAt: { type: 'string', autoUpdatedAt: true, },
     id: { type: 'number', autoMigrations: { autoIncrement: true } },

fastify.register(fastWater, { options })

// Usage in handler
const pets = await

Model definition

// ./model/Pet.js
module.exports = {
  identity: 'pet',
  attributes: {
    name: { type: 'string' },  


  • adapter: Any of sail's available adapters
  • adapterType: The name of adapter, example: 'mysql', 'sails-disk', etc
  • database:
    • name: The database name
    • user: The database user
    • password: The database password (optional)
    • host: The database host
    • port: The database port (optional)
  • modelPath: Path to the directory where your models are defined.
  • decoratorName: The fastify decorator name (optional - defaults to 'models')
  • modelDefaults: Object. Any model settings that will apply to all models.
    • Great for setting default primaryKey, datastore, fetchRecordsOnUpdate, fetchRecordsOnCreate
    • Will be overridden by specific model settings


Pull requests or issues welcome!