MCPcopy
hub / github.com/sequelize/sequelize / _mergeFunction

Method _mergeFunction

lib/model.js:800–825  ·  view source on GitHub ↗
(objValue, srcValue, key)

Source from the content-addressed store, hash-verified

798 }
799
800 static _mergeFunction(objValue, srcValue, key) {
801 if (Array.isArray(objValue) && Array.isArray(srcValue)) {
802 return _.union(objValue, srcValue);
803 }
804 if (['where', 'having'].includes(key)) {
805 if (srcValue instanceof Utils.SequelizeMethod) {
806 srcValue = { [Op.and]: srcValue };
807 }
808 if (_.isPlainObject(objValue) && _.isPlainObject(srcValue)) {
809 return Object.assign(objValue, srcValue);
810 }
811 } else if (key === 'attributes' && _.isPlainObject(objValue) && _.isPlainObject(srcValue)) {
812 return _.assignWith(objValue, srcValue, (objValue, srcValue) => {
813 if (Array.isArray(objValue) && Array.isArray(srcValue)) {
814 return _.union(objValue, srcValue);
815 }
816 });
817 }
818 // If we have a possible object/array to clone, we try it.
819 // Otherwise, we return the original value when it's not undefined,
820 // or the resulting object in that case.
821 if (srcValue) {
822 return Utils.cloneDeep(srcValue, true);
823 }
824 return srcValue === undefined ? objValue : srcValue;
825 }
826
827 static _assignOptions(...args) {
828 return this._baseMerge(...args, this._mergeFunction);

Callers 1

_defaultsOptionsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected