Registry / database / sails-hook-deep-orm

sails-hook-deep-orm

JSON →
library1.0.2jsnpmunverified

This Sails.js hook extends the Sails ORM with polymorphic associations, deep population, and inclusive population criteria for Waterline. Version 1.0.2 adds dynamic attribute methods and soft deletes. Unlike standard Sails associations, it allows wildcard polymorphic populations (populate('*')), deep nested populations (populate('home.occupants.statuses.*')), and conditional deep filtering (& operator). It also provides wildcard data extraction via sails.hooks.deeporm.wild.get(). Development is intermittent, with no recent releases.

npm install sails-hook-deep-orm
INSTALL
IMPORT
SIG · SAILS-HOOK-DEEP-OR
S
sails-hook-deep-orm
databasejavascriptv1.0.2
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.

module.exports
module.exports = { attributes: { ... } }
export default { attributes: { ... } }
Sails models use CommonJS module.exports, not ES module syntax.
populate()
await Model.find().populate('*')
Model.find().populate('*') (missing await)
populate() returns a promise; must be awaited.
sails.hooks.deeporm.wild.get
sails.hooks.deeporm.wild.get(records, '*.home.occupants.*.phones.0.number')
sails.hooks.deeporm.wild.get(records, '*.home.occupants.*.phones.number') (missing array index)
The wildcard pattern requires index for arrays, e.g., '0.number'.

Demonstrates install, model definitions for polymorphic associations, deep population, and wildcard data extraction.

// Install: npm install sails-hook-deep-orm // In your Sails model (e.g., api/models/Status.js): module.exports = { attributes: { affiliated: { collection: '*', }, }, }; // In another model (e.g., Person.js): module.exports = { attributes: { statuses: { collection: 'status', via: 'affiliated', }, }, }; // Usage in controller: const results = await Status.find().populate('*'); console.log(results); // Deep populate: const people = await Person.find().populate('home.occupants.statuses.*'); console.log(people); // Wild extract: const numbers = sails.hooks.deeporm.wild.get(people, '*.home.occupants.*.phones.0.number'); console.log(numbers);
Debug
Known issues
gotchaPolymorphic attribute name must be consistent across all referring models via 'via'.
fix
Ensure all models use the same attribute name (e.g., 'affiliated') in their 'via' association.
affects: >=1.0.0
gotchaDeep population syntax uses dot notation; incorrect dots or missing '&' for inclusive criteria leads to empty results.
fix
Use populate('home.occupants.statuses.*') for deep, and use '&' for inclusive: populate('home.occupants&state.statuses&phones.*&network').
affects: >=1.0.0
deprecatedDynamic attribute methods are marked as '[todo]' and not yet implemented; do not rely on them.
fix
Use standard Sails model methods or manually define them.
affects: 1.0.2
gotchaThe wildcard '*' in polymorphic populate() may return associations from all models; performance impact on large databases.
fix
Use specific paths or add criteria to limit results.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Unknown rule: affiliated
Sails ORM does not recognize the polymorphic attribute type 'collection: "*"' without the hook installed.
fix
Ensure sails-hook-deep-orm is installed and Sails is lifted with the hook loaded.
TypeError: Cannot read properties of undefined (reading 'get')
Attempting to use sails.hooks.deeporm.wild.get before the hook has initialized.
fix
Access the hook only after Sails has lifted (e.g., in controllers or after 'ready' event).
Invalid populate syntax: 'home.occupants.statuses.*'
The populate string contains a pattern that doesn't match any associations or uses incorrect syntax.
fix
Verify the model associations exist and match the dot-path exactly; use '&' for inclusive criteria as documented.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
Meta
1
Amazon
1
Resources
sails-hook-deep-orm — npm install sails-hook-deep-orm · libregistry