Skip to content

Commit

Permalink
Merge pull request #78 from Judahh/development
Browse files Browse the repository at this point in the history
fix query
  • Loading branch information
Judahh authored Oct 7, 2023
2 parents 3dadcda + c0ea7e4 commit e568fa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flexiblepersistence/sequelize",
"version": "2.2.27",
"version": "2.2.28",
"description": "A Sequelize implementation for Flexible Persistence's PersistenceAdapter",
"main": "dist/source/index.js",
"keywords": [
Expand Down
12 changes: 10 additions & 2 deletions source/sequelizePersistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,15 @@ export class SequelizePersistence implements IPersistence {
const newWI = await this.rearrangeInclude(where, include);
include = newWI.include;
where = newWI.where;
const queryBind = {
...(where || {}),
...(data || {}),
...(input?.item || {}),
};
const newQOptions = qOptions || {};
newQOptions.bind = { ...newQOptions.bind, ...queryBind };
let step = query
? this.sequelize.query(query, qOptions)
? await this.sequelize.query(query, newQOptions)
: data
? await model[method](
data,
Expand Down Expand Up @@ -423,7 +430,8 @@ export class SequelizePersistence implements IPersistence {
}
let received;
if (step) {
if (Array.isArray(step))
if (query) received = step[0];
else if (Array.isArray(step))
received = step.map(
(cOutput) => cOutput.dataValues || cOutput.AFFECTEDROWS
);
Expand Down

0 comments on commit e568fa0

Please sign in to comment.