(options, Model)
| 177 | |
| 178 | /* Used to map field names in attributes and where conditions */ |
| 179 | function mapOptionFieldNames(options, Model) { |
| 180 | if (Array.isArray(options.attributes)) { |
| 181 | options.attributes = options.attributes.map(attr => { |
| 182 | // Object lookups will force any variable to strings, we don't want that for special objects etc |
| 183 | if (typeof attr !== 'string') return attr; |
| 184 | // Map attributes to aliased syntax attributes |
| 185 | if (Model.rawAttributes[attr] && attr !== Model.rawAttributes[attr].field) { |
| 186 | return [Model.rawAttributes[attr].field, attr]; |
| 187 | } |
| 188 | return attr; |
| 189 | }); |
| 190 | } |
| 191 | |
| 192 | if (options.where && _.isPlainObject(options.where)) { |
| 193 | options.where = mapWhereFieldNames(options.where, Model); |
| 194 | } |
| 195 | |
| 196 | return options; |
| 197 | } |
| 198 | exports.mapOptionFieldNames = mapOptionFieldNames; |
| 199 | |
| 200 | function mapWhereFieldNames(attributes, Model) { |
no test coverage detected