* 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)
| 4709 | * @private |
| 4710 | */ |
| 4711 | function 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 | |
| 4733 | function combineWheresWithAnd(whereA, whereB) { |
| 4734 | const unpackedA = unpackAnd(whereA); |
no outgoing calls
no test coverage detected