MCPcopy
hub / github.com/sequelize/sequelize / mapOptionFieldNames

Function mapOptionFieldNames

lib/utils.js:166–184  ·  view source on GitHub ↗
(options, Model)

Source from the content-addressed store, hash-verified

164
165/* Used to map field names in attributes and where conditions */
166function 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}
185exports.mapOptionFieldNames = mapOptionFieldNames;
186
187function mapWhereFieldNames(attributes, Model) {

Callers 2

mapFinderOptionsFunction · 0.85
mapWhereFieldNamesFunction · 0.85

Calls 1

mapWhereFieldNamesFunction · 0.85

Tested by

no test coverage detected