loopback-component-sqlizer
v0.0.4
Published
Usefull mixins for sql databases
Readme
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
Install the module in you project
Open server/model-config.json and add
loopback-component-sqlizer/libto the_meta.mixinsnode.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'
}
}
}
}
]