Comments (3)
Also, we likely need to do some more type checking on the $and
. Note in this line that we assume the $and
is an array. But the code also potentially returns an object instead of an array.
feathers-sequelize/lib/index.js
Line 169 in db4b5ff
So if
$and
works with an object and not just an array, when we need to check that. I think it is most common that its an array so we should also return an array.
Something like
applyAndQuery(where, id) {
const { and } = this.Op;
const IdQuery = { [this.id]: id };
const newWhere = Object.assign({}, where);
if (!newWhere[and]) {
newWhere[and] = [IdQuery]
return newWhere;
}
if (Array.isArray(newWhere[and])) {
newWhere[and] = [...newWhere[and], idQuery];
return newWhere;
}
newWhere[and] = [newWhere[and], idQuery];
return newWhere;
}
from feathers-sequelize.
Good catch! We should add a test for that. Maybe even on @feathersjs/adapter-tests
and we could add $and
to the official supported operators list at https://docs.feathersjs.com/api/databases/querying.html.
Op.and
and Op.or
can be used as an object, indeed (see https://sequelize.org/v6/manual/model-querying-basics.html#examples-with--code-op-and--code--and--code-op-or--code-). But I believe at the root level they're always meant to be arrays. It makes sense if they're nested within a column query like:
where: {
rank: {
[Op.and]: {
[Op.lt]: 1000,
[Op.eq]: null
}
},
}
from feathers-sequelize.
Related Issues (20)
- 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
- How can I use a limit and a required in an include? HOT 9
- 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 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)
- feathers sequlize type confict when overwritting find and calling super.find HOT 1
- Support withSchema [with PR] HOT 3
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.