herteby:denormalize

v0.4.0Published 5 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:'one',
3  collection:ChildCollection,
4  fields:['name','title'],
5  referenceField:'childId',
6  cacheField:'_cache'
7})

Nested referenceFields

For "one" and "inversed", nested referenceFields are simply declared like referenceField:'nested.reference.field'

For "many" and "many-inversed", 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 your browser