loopback-denormalize
v0.0.6
Published
Module for denormalizing association attributes in loopback mongodb models
Downloads
9
Readme
loopback-denormalize
Module for denormalizing association attributes in loopback mongodb models
Install
- Add
"loopback-denormalize": "latest"
to yourpackage.json
file then runnpm install
OR runnpm install loopback-denormalize
- Set the module in your Entity.js
Sample: Product with many tags and on category.
require('loopback-denormalize')(Product,
{
tags: { attributes: ['id', 'text'], type: 'hasMany' },
category: { attributes: ['id', 'title'], type: 'hasOne' }
});
- See the results
GET product.json
{
id: ....,
title: ....,
_tags:[{ id:'dsgsdg', text:'tag1'}, { id:'fsfsffff', text:'tag2'}],
_category:{ id:'dsgsdg', title:'My Category'}
}
Info
Methods added to your entity
- Before Save observer who automatically denormalize fields
- Refresh remote method
entities/denormalize/:id
Sample: http://mysite/api/products/denormalize/565f69bbd3810ed01977cdf1.
Enjoy ;)