Registry / database / sails-orm-hook

sails-orm-hook

JSON →
library3.30.0jsnpmunverified

Core Sails.js hook that integrates Waterline ORM. Version 3.30.0. Provides loading of adapters, model hydration, auto-migration prompts, and global model exposure. Forks from official Sails core to implement additional features without breaking changes. Relies on moduleloader and userconfig hooks. Disabling this hook breaks blueprints and pubsub hooks. Defaults to sails-disk adapter and global model variables.

npm install sails-orm-hook
INSTALL
IMPORT
SIG · SAILS-ORM-HOOK
S
sails-orm-hook
databasejavascriptv3.30.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sails-orm-hook
const sails = require('sails'); // Hook loaded automatically
require('sails-orm-hook')
This is a Sails core hook, not a standalone module. Import via Sails, not directly.

Loads Sails with the ORM hook, creates a model, and logs the result. Uses sails-disk in-memory.

const sails = require('sails'); const log = console.log; sails.load({ hooks: { orm: require('sails-orm-hook') }, log: { level: 'warn' }, models: { migrate: 'alter', datastore: 'default' }, datastores: { default: { adapter: require('sails-disk'), inMemoryOnly: true } } }, async (err) => { if (err) { log('Error loading Sails:', err); return; } // Access models via sails.models const User = sails.models.user; try { const user = await User.create({ name: 'Alice' }).fetch(); log('Created user:', user); } catch(e) { log('Error:', e); } sails.lower(); });
Debug
Known issues
gotchaAuto-migration prompts when migrate not set
fix
Set sails.config.models.migrate to 'safe', 'alter', or 'drop' in production.
affects: >=1.0.0
gotchaModel global variables enabled by default
fix
Set sails.config.globals.models to false if you prefer explicit access via sails.models.
affects: >=1.0.0
Errors
Common errors & fixes
Error: No adapter found for model '...'
Missing or misconfigured datastore adapter
fix
Install and configure a valid adapter (e.g., sails-disk): npm install sails-disk --save, and set sails.config.datastores.default.adapter
Error: A hook (orm) failed to load!
Dependency hook (moduleloader or userconfig) not loaded first
fix
Ensure sails.config.hooks includes moduleloader and userconfig, and they load before orm.
Error: migrate is not set; something else (probably a watermark) is using auto-migration without permission
Missing 'migrate' configuration in production
fix
Set sails.config.models.migrate explicitly to 'safe' or another value.
Upgrade
Version history
3.30.0latest on npm
Audit
Dependencies
sailsrequiredCore runtime; hook system
waterlinerequiredORM library
sails-diskoptionalDefault datastore adapter
Agent activity
8 hits · last 30 days
node
6
Meta
1
Resources
sails-orm-hook — npm install sails-orm-hook · libregistry