Comments (9)
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.
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.
I have the same problem too, anyone knows how to do this?
from feathers-sequelize.
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.
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.
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.
I am not sure what arguments
is. It should be hook.params.query
instead of hook.arguments.query
.
from feathers-sequelize.
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.
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)
- RangeError: "size" argument must not be larger than 2147483647
- Bug: patch:multi only patches 10 items with default pagination HOT 7
- Unable to modify hook result of referenced models HOT 1
- app.service('users').get(message.userId, params) returns createdAt and updatedAt dates as string rather than Date object on SQLite
- Support Deep Aware for JSON Objects on Patch HOT 1
- Query by Association HOT 5
- id is not set correctly to a non-null value when using multi-create and throws an error instead of creating
- Got 404 No Record Found while using include in before get hooks HOT 1
- Optimize multi patch when $returning is false. HOT 3
- Use proper $and in patch and remove methods HOT 3
- Use consistent $select in all methods, optimize select function HOT 2
- iLike method with accent. HOT 1
- how to set field to NULL on patch request?
- Allow join queries on remove HOT 1
- Better handle paranoid models HOT 2
- Since version 6.4.0 getting "error: GeneralError: column "id" does not exist" HOT 1
- feathers-sequelize remove method rewrite breaking change when deleting multiple items without id in table
- Associations Suggestion
- Service .find() method return a wrong type (not paginated)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feathers-sequelize.