0.0.4 • Published 8 years ago
loopback-component-sqlizer v0.0.4
loopback-component-sqlizer
Component to add sql methods to models
Description
This module enable to make sql join request with loopback through the api.
Installation
1) Install the module in you project
2) Open server/model-config.json and add loopback-component-sqlizer/lib
to the _meta.mixins
node.
3) Enable the mixin for the model by adding this in your model.json
"mixins": {
"Sqlizer": {
"findOne": {
"method": true,
"remote": true
},
"find": {
"method": true,
"remote": true
}
}
}
How to use it
Use it like if you were using loopback API. Imagine you have a Post model that contains Comments. If you want to get the posts having comment with 'hi' in the comment just do a GET on /sql-find
include: ['comments'],
join: [
{
relation: 'comments',
scope: {
where: {
content: {
like: 'hi'
}
}
}
}
]