Skip to content

Commit

Permalink
fix(types): add parent transaction and enhance where parameters (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSchick authored and sushantdhiman committed Apr 8, 2019
1 parent 57aba97 commit 47c5f30
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion types/lib/sequelize.d.ts
Expand Up @@ -1336,7 +1336,7 @@ export function or(...args: (WhereOperators | WhereAttributeHash | Where)[]): Or
export function json(conditionsOrPath: string | object, value?: string | number | boolean): Json;

export type AttributeType = Fn | Col | Literal | ModelAttributeColumnOptions | string;
export type LogicType = Fn | Col | Literal | OrOperator | AndOperator | string;
export type LogicType = Fn | Col | Literal | OrOperator | AndOperator | WhereOperators | string;

/**
* A way of specifying attr = condition.
Expand Down
4 changes: 4 additions & 0 deletions types/lib/transaction.d.ts
Expand Up @@ -129,6 +129,10 @@ export interface TransactionOptions extends Logging {
isolationLevel?: Transaction.ISOLATION_LEVELS;
type?: Transaction.TYPES;
deferrable?: string | Deferrable;
/**
* Parent transaction.
*/
transaction?: Transaction;
}

export default Transaction;
7 changes: 7 additions & 0 deletions types/test/transaction.ts
Expand Up @@ -29,3 +29,10 @@ async function transact() {
}

transact();

async function nestedTransact() {
const tr = await sequelize.transaction({
transaction: await sequelize.transaction(),
});
await tr.commit();
}
6 changes: 5 additions & 1 deletion types/test/where.ts
@@ -1,4 +1,4 @@
import { AndOperator, fn, Model, Op, OrOperator, Sequelize, WhereOperators, WhereOptions } from 'sequelize';
import { AndOperator, fn, Model, Op, OrOperator, Sequelize, WhereOperators, WhereOptions, where as whereFn } from 'sequelize';
import Transaction from '../lib/transaction';

class MyModel extends Model {
Expand Down Expand Up @@ -252,3 +252,7 @@ where = {
where = {
[Op.gt]: fn('NOW'),
};

where = whereFn('test', {
[Op.gt]: new Date(),
});

0 comments on commit 47c5f30

Please sign in to comment.