loopback-component-sqlizer

0.0.4 • Public • Published

loopback-component-sqlizer

Component to add sql methods to models

Build Status codecov.io

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'
        }
      }
    }
  }
]

Package Sidebar

Install

npm i loopback-component-sqlizer

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • jdrouet