(options, Model)
| 164 | |
| 165 | /* Used to map field names in attributes and where conditions */ |
| 166 | function mapOptionFieldNames(options, Model) { |
| 167 | if (Array.isArray(options.attributes)) { |
| 168 | options.attributes = options.attributes.map(attr => { |
| 169 | // Object lookups will force any variable to strings, we don't want that for special objects etc |
| 170 | if (typeof attr !== 'string') return attr; |
| 171 | // Map attributes to aliased syntax attributes |
| 172 | if (Model.rawAttributes[attr] && attr !== Model.rawAttributes[attr].field) { |
| 173 | return [Model.rawAttributes[attr].field, attr]; |
| 174 | } |
| 175 | return attr; |
| 176 | }); |
| 177 | } |
| 178 | |
| 179 | if (options.where && _.isPlainObject(options.where)) { |
| 180 | options.where = mapWhereFieldNames(options.where, Model); |
| 181 | } |
| 182 | |
| 183 | return options; |
| 184 | } |
| 185 | exports.mapOptionFieldNames = mapOptionFieldNames; |
| 186 | |
| 187 | function mapWhereFieldNames(attributes, Model) { |
no test coverage detected