GithubHelp home page GithubHelp logo

Comments (9)

MariaCamilaCubides avatar MariaCamilaCubides commented on May 26, 2024 3

Thank you so much, that works with a little change. I had to add the property duplicating: false because before that I had missing FROM-clause entry for table "executions" at find execution-groups error, so I searched and found a solution here #248.

hook.params.query = {
    '$executions.startedOn$': null,
    '$executions.finishedOn$': null,
    $limit: 1,
  };
  const association = {
    include: [
      {
        model: hook.app.service('executions').Model,
        as: 'executions',
        duplicating: false,
      },
    ],
  };
  hook.params.sequelize = Object.assign(association, { raw: false });

from feathers-sequelize.

chrisbag avatar chrisbag commented on May 26, 2024 1

For those ending up on this thread, duplicating false does solve the issue but messes up the limit and offset. For this to work you need to make separate queries (separate:true). This works for one-to-many relations but does not work with many-to-many as is indicated in this thread which is 7 years old and has still has not been solved sequelize/sequelize#4525 and sequelize/sequelize#8457

from feathers-sequelize.

koraniar avatar koraniar commented on May 26, 2024

I have the same problem too, anyone knows how to do this?

from feathers-sequelize.

DaddyWarbucks avatar DaddyWarbucks commented on May 26, 2024

This is actually returning the proper results for your query. Your query is saying "return all results, and include executions where startedOn and finsihed on are null on those results", not "return only results that that have executions where startedOn and finishedOn are null". You are looking for "top level" queries via $nested.column.syntax$. Check this link out: https://sequelize.org/master/manual/eager-loading.html#complex-where-clauses-at-the-top-level

from feathers-sequelize.

DaddyWarbucks avatar DaddyWarbucks commented on May 26, 2024

This is the query you are looking for

.find({
  query: {
     required: true,
    '$executions.startedOn$': null,
    '$executions. finishedOn $': null,
    $limit: 1
  },
  sequelize: {
    include: [{
      model: excutionsModel,
      as: 'executions'
    }]
  }
})

from feathers-sequelize.

MariaCamilaCubides avatar MariaCamilaCubides commented on May 26, 2024

Hi @DaddyWarbucks, thank you for your response. I tried that query but it doesn't work as I expected, the result of the query brings all the data of both tables.

hook.arguments.query = {
    required: true,
    '$executions.startedOn$': null,
    '$executions.finishedOn$': null,
    $limit: 1,
  };
  const association = {
    include: [
      {
        model: hook.app.service('executions').Model,
        as: 'executions',
      },
    ],
  };
  hook.params.sequelize = Object.assign(association, { raw: false });

I solved it by denormalizing the table Executions with the necessary information of the columns startedOn and finishedOn for each execution.

from feathers-sequelize.

DaddyWarbucks avatar DaddyWarbucks commented on May 26, 2024

I am not sure what arguments is. It should be hook.params.query instead of hook.arguments.query.

from feathers-sequelize.

MariaCamilaCubides avatar MariaCamilaCubides commented on May 26, 2024

You are right. I change for hook.params.query but I got this error Invalid query parameter $executions.startedOn$ at find execution-groups. I got this error in the past months but I couldn't solve it.

from feathers-sequelize.

DaddyWarbucks avatar DaddyWarbucks commented on May 26, 2024

You have to whitelist the $executions.startedOn$ in the service options. See the README for more info: https://github.com/feathersjs-ecosystem/feathers-sequelize#serviceoptions

const options = {
    Model,
    paginate,
    whitelist: ['$executions.startedOn$']
  };

from feathers-sequelize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.