herteby:denormalize

v0.2.1Published 7 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

denormalize

Simple denormalization for Meteor

meteor add herteby:denormalize

API

1ParentCollection.cache({
2  type:'single',
3  collection:ChildCollection,
4  fields:['name','title'],
5  referenceField:'childId',
6  cacheField:'_cache'
7})

Nested referenceFields

For 'single' and 'inverse', nested referenceFields are simply declared like 'nested.reference.field' For 'many', if the referenceField is an Array containing objects, a colon is used to show where the Array starts.

Example: If the parent doc looks like this:

1{
2  references:{
3    users:[{_id:'user1'}, {_id:'user2'}]
4  }
5}

The referenceField string should be 'references.users:_id'

Testing the package

meteor test-packages packages/denormalize --driver-package=practicalmeteor:mocha
open localhost:3000 in browser