* Get an object representing the query for this instance, use with `options.where` * * @param {boolean} [checkVersion=false] include version attribute in where hash * * @returns {object}
(checkVersion)
| 3579 | * @returns {object} |
| 3580 | */ |
| 3581 | where(checkVersion) { |
| 3582 | const where = this.constructor.primaryKeyAttributes.reduce((result, attribute) => { |
| 3583 | result[attribute] = this.get(attribute, { raw: true }); |
| 3584 | return result; |
| 3585 | }, {}); |
| 3586 | |
| 3587 | if (_.size(where) === 0) { |
| 3588 | return this.constructor.options.whereCollection; |
| 3589 | } |
| 3590 | const versionAttr = this.constructor._versionAttribute; |
| 3591 | if (checkVersion && versionAttr) { |
| 3592 | where[versionAttr] = this.get(versionAttr, { raw: true }); |
| 3593 | } |
| 3594 | return Utils.mapWhereFieldNames(where, this.constructor); |
| 3595 | } |
| 3596 | |
| 3597 | toString() { |
| 3598 | return `[object SequelizeInstance:${this.constructor.name}]`; |
no test coverage detected