0
votes

This current code is working :

  app.models.AvionPiloteAutorisation.find({
    "where": {
      "idAvion": avion.idAvion
    },
    "include": ["pilote"]
  }, function(err, pilotes) { ... }

But this :

  app.models.AvionPiloteAutorisation.find({
    "filter": {
      "where": {
        "idAvion": avion.idAvion
      },
      "include": {
        "relation": "pilote"
      }
    }
  })

fail. It's suppose to be the same, right ?

I'm trying to add some information using related model 'Utilisateur'

  app.models.AvionPiloteAutorisation.find({
    "filter": {
      "where": {
        "idAvion": avion.idAvion
      },
      "include": {"relation": "pilote", "scope": {"include": ["utilisateur"]}}
    }
  })

What am I doing wrong ?

Thanks.

1
What does it mean "fails"? It does not filter data or error has occurred? If filtering data is a problem then In your second code snippet your query is malformed. You don't need "filter: {}" in your expression. It should be {"where": { "idAvion": avion.idAvion }, "include": { "relation": "pilote" }} - A.Z.
It doesn't retreive the data as expected. I'll try without filter. - Romain Quellec
Thank you. I thought the filter keyword was mandatory in case of complex query. - Romain Quellec
Not sure about this, but maybe try to make it "include": [ { ... } ] (notice that I made it an array with an object versus just an object). - Jordan Kasper

1 Answers

0
votes

The answer to your first question asking about why your second chunk of code is failing is because the syntax involving "filter" is used when you are hitting the end point using Angular SDK.
I think this code will achieve what you are trying to do here:-

  app.models.AvionPiloteAutorisation.find({ "include":[{ "pilote": "utilisateur" }], "where":{ "idAvion": avion.idAvion } })