MCPcopy
hub / github.com/sequelize/sequelize / mapWhereFieldNames

Function mapWhereFieldNames

src/utils.js:200–232  ·  view source on GitHub ↗
(attributes, Model)

Source from the content-addressed store, hash-verified

198exports.mapOptionFieldNames = mapOptionFieldNames;
199
200function mapWhereFieldNames(attributes, Model) {
201 if (attributes) {
202 attributes = cloneDeep(attributes);
203 getComplexKeys(attributes).forEach(attribute => {
204 const rawAttribute = Model.rawAttributes[attribute];
205
206 if (rawAttribute && rawAttribute.field !== rawAttribute.fieldName) {
207 attributes[rawAttribute.field] = attributes[attribute];
208 delete attributes[attribute];
209 }
210
211 if (_.isPlainObject(attributes[attribute])
212 && !(rawAttribute && (
213 rawAttribute.type instanceof DataTypes.HSTORE
214 || rawAttribute.type instanceof DataTypes.JSON))) { // Prevent renaming of HSTORE & JSON fields
215 attributes[attribute] = mapOptionFieldNames({
216 where: attributes[attribute]
217 }, Model).where;
218 }
219
220 if (Array.isArray(attributes[attribute])) {
221 attributes[attribute].forEach((where, index) => {
222 if (_.isPlainObject(where)) {
223 attributes[attribute][index] = mapWhereFieldNames(where, Model);
224 }
225 });
226 }
227
228 });
229 }
230
231 return attributes;
232}
233exports.mapWhereFieldNames = mapWhereFieldNames;
234
235/* Used to map field names in values */

Callers 1

mapOptionFieldNamesFunction · 0.85

Calls 3

cloneDeepFunction · 0.85
getComplexKeysFunction · 0.85
mapOptionFieldNamesFunction · 0.85

Tested by

no test coverage detected