Skip to content

Commit

Permalink
Add options to sync (#124)
Browse files Browse the repository at this point in the history
Sequelize sync model function can take options as argument.
  • Loading branch information
hadrien-f authored Jan 12, 2021
1 parent 6b60a8f commit 3946452
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ app.use(
);
// continue as normal
```

If you want SequelizeStore to create/sync the database table for you, you can call `sync()` against an instance of `SequelizeStore` - this will run a sequelize `sync()` operation on the model for an initialized SequelizeStore object:
If you want SequelizeStore to create/sync the database table for you, you can call `sync()` against an instance of `SequelizeStore` along with [options](https://sequelize.org/master/class/lib/model.js~Model.html#static-method-sync) if needed. This will run a sequelize `sync()` operation on the model for an initialized SequelizeStore object :

```javascript
var myStore = new SequelizeStore({
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store } from 'express-session';
import { Sequelize, Model } from 'sequelize';
import { Sequelize, SyncOptions } from 'sequelize';

interface DefaultFields {
data: string;
Expand All @@ -20,7 +20,7 @@ interface SequelizeStoreOptions {
}

declare class SequelizeStore extends Store {
sync(): void
sync(options?: SyncOptions): void
touch: (sid: string, data: any, callback?: (err: any) => void) => void
stopExpiringSessions: () => void
}
Expand Down
4 changes: 2 additions & 2 deletions lib/connect-session-sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ module.exports = function SequelizeSessionInit (Store) {
}
}

sync () {
return this.sessionModel.sync()
sync (options) {
return this.sessionModel.sync(options)
}

get (sid, fn) {
Expand Down

0 comments on commit 3946452

Please sign in to comment.