* 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)
| 3453 | * @returns {object} |
| 3454 | */ |
| 3455 | where(checkVersion) { |
| 3456 | const where = this.constructor.primaryKeyAttributes.reduce((result, attribute) => { |
| 3457 | result[attribute] = this.get(attribute, { raw: true }); |
| 3458 | return result; |
| 3459 | }, {}); |
| 3460 | |
| 3461 | if (_.size(where) === 0) { |
| 3462 | return this.constructor.options.whereCollection; |
| 3463 | } |
| 3464 | const versionAttr = this.constructor._versionAttribute; |
| 3465 | if (checkVersion && versionAttr) { |
| 3466 | where[versionAttr] = this.get(versionAttr, { raw: true }); |
| 3467 | } |
| 3468 | return Utils.mapWhereFieldNames(where, this.constructor); |
| 3469 | } |
| 3470 | |
| 3471 | toString() { |
| 3472 | return `[object SequelizeInstance:${this.constructor.name}]`; |
no test coverage detected