Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

jdrouet/loopback-component-sqlizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Component to add sql methods to models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published