MCPcopy Index your code
hub / github.com/sequelize/sequelize / unpackAnd

Function unpackAnd

src/model.js:4711–4731  ·  view source on GitHub ↗

* Unpacks an object that only contains a single Op.and key to the value of Op.and * * Internal method used by combineWheresWithAnd * * @param {WhereOptions} where The object to unpack * @example `{ [Op.and]: [a, b] }` becomes `[a, b]` * @example `{ [Op.and]: { key: val } }` becomes `{

(where)

Source from the content-addressed store, hash-verified

4709 * @private
4710 */
4711function unpackAnd(where) {
4712 if (!_.isObject(where)) {
4713 return where;
4714 }
4715
4716 const keys = Utils.getComplexKeys(where);
4717
4718 // object is empty, remove it.
4719 if (keys.length === 0) {
4720 return;
4721 }
4722
4723 // we have more than just Op.and, keep as-is
4724 if (keys.length !== 1 || keys[0] !== Op.and) {
4725 return where;
4726 }
4727
4728 const andParts = where[Op.and];
4729
4730 return andParts;
4731}
4732
4733function combineWheresWithAnd(whereA, whereB) {
4734 const unpackedA = unpackAnd(whereA);

Callers 1

combineWheresWithAndFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected