-1

I have this SQL query:


    SELECT cvs.overview, 
        usr.username, usr.email, usr.id, 
        usrd.firstname, usrd.lastname, usrd.profilepicture, usrd.hourlyrate,
        skill.name AS skill
    FROM public."Cvs" AS cvs
    LEFT JOIN public."Users" AS usr ON cvs.usersid = usr.id
    LEFT JOIN public."UserDetails" AS usrd ON usr.id = usrd.usersid
    LEFT JOIN public."Cvs_Skills" AS cvskill ON cvs.id = cvskill.cvsid
    LEFT JOIN public."Skills" AS skill ON cvskill.skillid = skill.id
    WHERE usr.username ILIKE '%node%'
      OR skill.name ILIKE '%node%'

I need to know how to do it in the Strongloop ORM way

1 Answers1

2

You should step away from thinking in SQL queries with loopback. SQL queries are abstracted, well, because there is an ORM that does just that.

Instead, define models like

  • MyUser with properties like firstname, lastname, profilepicture, hourlyrate,
  • Skill with property name for instance

Then, create a relation MyUser hasMany Skill, etc. Afterwards, you will be able to query all skills for a given user, add new skills to a user, etc.

This is just to get you started, you should take the time to read the documentation to understand how to work with loopback, and how to do everything I just mentionned. This is basic stuff so you will have not trouble doing it.

Overdrivr
  • 6,296
  • 5
  • 44
  • 70