不要怂,就是干,撸起袖子干!

Commit 47c5f30f by Simon Schick Committed by Sushant

fix(types): add parent transaction and enhance `where` parameters (#10726)

1 parent 57aba974
......@@ -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.
......
......@@ -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;
......@@ -29,3 +29,10 @@ async function transact() {
}
transact();
async function nestedTransact() {
const tr = await sequelize.transaction({
transaction: await sequelize.transaction(),
});
await tr.commit();
}
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 {
......@@ -252,3 +252,7 @@ where = {
where = {
[Op.gt]: fn('NOW'),
};
where = whereFn('test', {
[Op.gt]: new Date(),
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!