Make a join query in loopback.io

前端 未结 1 1842
猫巷女王i
猫巷女王i 2021-01-14 11:42

I am trying to build a simple application using loopback.io as process of my learning. I have set up the project, created models and apis are working fine.

Now I am t

1条回答
  •  囚心锁ツ
    2021-01-14 12:21

    You don't need to pass sql query. You can query data using PersistedModel find method by using include filter

    In order to use include filter you have to create model relation.

    For example:

    Note relation:

    "relations": {
      "stories": {
        "type": "hasMany",
        "model": "Story",
        "foreignKey": "noteId"
      }
    },
    

    Query:

    Note.find({include: ['stories']}, function(err, data) { ... });
    

    0 讨论(0)
提交回复
热议问题