From e596e6d365a3e46859e7d7bafcc3e54d286656cf Mon Sep 17 00:00:00 2001 From: chenos Date: Fri, 20 May 2022 12:18:46 +0800 Subject: [PATCH] fix: missing isTruly/isFalsy filter operators #390 --- .../core/database/src/operators/boolean.ts | 18 ++++++++++++++++++ packages/core/database/src/operators/index.ts | 1 + 2 files changed, 19 insertions(+) create mode 100644 packages/core/database/src/operators/boolean.ts diff --git a/packages/core/database/src/operators/boolean.ts b/packages/core/database/src/operators/boolean.ts new file mode 100644 index 000000000..a37c6d64f --- /dev/null +++ b/packages/core/database/src/operators/boolean.ts @@ -0,0 +1,18 @@ +import { Op } from 'sequelize'; + +export default { + $isFalsy() { + return { + [Op.or]: { + [Op.is]: null, + [Op.eq]: false, + }, + }; + }, + + $isTruly() { + return { + [Op.eq]: true, + }; + }, +}; diff --git a/packages/core/database/src/operators/index.ts b/packages/core/database/src/operators/index.ts index db4cbca8a..72b1ace2c 100644 --- a/packages/core/database/src/operators/index.ts +++ b/packages/core/database/src/operators/index.ts @@ -6,4 +6,5 @@ export default { ...require('./string').default, ...require('./ne').default, ...require('./notIn').default, + ...require('./boolean').default, };