MCPcopy Index your code
hub / github.com/sequelize/sequelize / mapOptionFieldNames

Function mapOptionFieldNames

src/utils.js:179–197  ·  view source on GitHub ↗
(options, Model)

Source from the content-addressed store, hash-verified

177
178/* Used to map field names in attributes and where conditions */
179function 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}
198exports.mapOptionFieldNames = mapOptionFieldNames;
199
200function mapWhereFieldNames(attributes, Model) {

Callers 2

mapFinderOptionsFunction · 0.85
mapWhereFieldNamesFunction · 0.85

Calls 1

mapWhereFieldNamesFunction · 0.85

Tested by

no test coverage detected