Registry / database / dogwater

dogwater

JSON →
library2.3.0jsnpmunverified

A hapi plugin integrating Waterline ORM, currently at v2.3.0. It allows defining models, adapters, and connections for Waterline within a hapi server, and provides convenience methods like `server.dogwater()`, `server.collections()`, and `request.collections()` to access Waterline collections. Supports multi-plugin deployments with collision protection. Works with hapi >=10 <17 and waterline >=0.10.0 <0.13.0. Last updated in 2019; no major releases since v2. Alternative to using Waterline standalone with hapi.

npm install dogwater
INSTALL
IMPORT
SIG · DOGWATER
D
dogwater
databasejavascriptv2.3.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.

Dogwater
const Dogwater = require('dogwater')
import Dogwater from 'dogwater'
Package is CJS-only; ESM import will fail. Use require.
server.dogwater()
server.dogwater({ identity: 'model', connection: 'conn', attributes: {} })
server.dogwater('model', {})
Accepts a single config object, not separate arguments.
request.collections()
const Cols = request.collections(); const Model = Cols.modelname
const Model = request.collections().modelname
request.collections() is a method that returns an object. Call it each time.
server.collections()
const Cols = server.collections(); const Model = Cols.modelname
server.collections.modelname
server.collections is a function; must be invoked.

Shows full hapi server setup with Dogwater, including model definition, route using request.collections(), and startup with data creation.

const Hapi = require('hapi'); const Dogwater = require('dogwater'); const Memory = require('sails-memory'); const server = new Hapi.Server(); server.connection({ port: 3000 }); server.route({ method: 'get', path: '/dogs/{id}', handler: function (request, reply) { const Dogs = request.collections().dogs; reply(Dogs.findOne(request.params.id)); } }); server.register({ register: Dogwater, options: { adapters: { memory: Memory }, connections: { simple: { adapter: 'memory' } } } }, (err) => { if (err) throw err; server.dogwater({ identity: 'dogs', connection: 'simple', attributes: { name: 'string' } }); server.start((err) => { if (err) throw err; const Dogs = server.collections().dogs; Dogs.create([ { name: 'Guinness' }, { name: 'Sully' }, { name: 'Ren' } ]).then(() => { console.log(`Go find some dogs at ${server.info.uri}`); }).catch((err) => console.error(err)); }); });
Debug
Known issues
breakingDogwater v2.0.0 dropped support for hapi <10 and waterline <0.10. Removed server.dogwater() model registration from options; models must be registered via the server.dogwater() method.
fix
Upgrade to hapi 10+ and waterline 0.10+. Use server.dogwater() to register models after registration.
affects: >=2.0.0
deprecatedPackage is in maintenance mode. The peer dependency range for waterline (>=0.10.0 <0.13.0) is outdated; Waterline is no longer actively maintained and newer versions may not be compatible.
fix
Consider migrating to a different ORM or using Waterline standalone with hapi.
affects: >=2.0.0
gotchamodel definitions must have an `identity` property. Duplicate identities across plugins will cause registration to fail.
fix
Ensure each model has a unique identity string (lowercase, typically plural).
affects: >=1.0.0
gotchaDogwater requires a connection configuration with a valid adapter. Using an adapter name that was not registered via `adapters` option will throw a runtime error.
fix
Register all adapters in the `adapters` option when registering Dogwater on the root server.
affects: >=1.0.0
Errors
Common errors & fixes
AssertionError [ERR_ASSERTION]: Model must have an identity
Model definition missing `identity` property.
fix
Add `identity: 'mymodel'` to the model config object passed to server.dogwater().
Error: Adapter 'xyz' is not defined
Adapter name used in connection configuration but not registered in `adapters` option.
fix
Include the adapter in the `adapters` option when registering Dogwater: `adapters: { xyz: require('sails-xyz') }`
TypeError: request.collections is not a function
Calling request.collections() on a request that hasn't been decorated by Dogwater (e.g., in a plugin that doesn't have Dogwater registered).
fix
Ensure Dogwater is registered in the plugin or at the server level, and that the plugin exposes `request.collections`.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
hapirequiredpeer dependency: hapi framework required >=10 <17
waterlinerequiredpeer dependency: Waterline ORM required >=0.10.0 <0.13.0
Agent activity
9 hits · last 30 days
node
8
Resources
dogwater — npm install dogwater · libregistry