Skip to content

Commit

Permalink
TypeormStore: Fix update with latest TypeORM
Browse files Browse the repository at this point in the history
  • Loading branch information
nykula committed May 4, 2018
1 parent 206f8b7 commit 1d57761
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"express-session": "^1.15.6"
},
"peerDependencies": {
"typeorm": "^0.1.2"
"typeorm": "^0.1.2 || ^0.2.5"
},
"scripts": {
"format": "tslint --fix 'src/**/*.ts'",
Expand Down
10 changes: 6 additions & 4 deletions src/app/TypeormStore/TypeormStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Ttl = number | ((store: TypeormStore, sess: any, sid?: string) => nu
export class TypeormStore extends Store {
private debug = Debug("connect:typeorm");

private repository: Repository<ISession>;
private repository!: Repository<ISession>;

private ttl: Ttl | undefined;

Expand Down Expand Up @@ -120,9 +120,11 @@ export class TypeormStore extends Store {
const ttl = this.getTTL(sess);

this.debug('EXPIRE "%s" ttl:%s', sid, ttl);
this.repository.updateById(sid, {
expiredAt: Date.now() + ttl * 1000,
})
this.repository
.createQueryBuilder()
.update({ expiredAt: Date.now() + ttl * 1000 })
.whereInIds([sid])
.execute()
.then(() => {
this.debug("EXPIRE complete");
fn();
Expand Down

0 comments on commit 1d57761

Please sign in to comment.