Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequelize store broken with sequelize 5 #26

Open
armellarcier opened this issue Jun 23, 2020 · 0 comments
Open

Sequelize store broken with sequelize 5 #26

armellarcier opened this issue Jun 23, 2020 · 0 comments

Comments

@armellarcier
Copy link

armellarcier commented Jun 23, 2020

Use of global.sequelize and of $lte operator.

I use this patch (with patch-package)

diff --git a/node_modules/koa2-ratelimit/src/SequelizeStore.js b/node_modules/koa2-ratelimit/src/SequelizeStore.js
index f5bceb4..ac3b23b 100644
--- a/node_modules/koa2-ratelimit/src/SequelizeStore.js
+++ b/node_modules/koa2-ratelimit/src/SequelizeStore.js
@@ -1,4 +1,5 @@
 const Sequelize = require('sequelize');
+const Op = Sequelize.Op;
 
 const Store = require('./Store.js');
 
@@ -116,7 +117,7 @@ class SequelizeStore extends Store {
     }
 
     async _increment(table, where, nb = 1, field) {
-        return table.update({ [field]: global.sequelize.literal(`${field} + ${nb}`) }, { where });
+        return table.update({ [field]: this.sequelize.literal(`${field} + ${nb}`) }, { where });
     }
 
     // remove all if time is passed
@@ -124,7 +125,7 @@ class SequelizeStore extends Store {
         const now = new Date();
         await table.destroy({
             where: {
-                date_end: { $lte: now.getTime() },
+                date_end: { [Op.lte]: now.getTime() },
             },
         });
     }
@armellarcier armellarcier changed the title use of global.sequelize in Sequelize store gives error Sequelize store broken with sequelize 5 Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant