MCPcopy
hub / github.com/sequelize/sequelize / _injectAttributes

Method _injectAttributes

lib/associations/belongs-to.js:81–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79
80 // the id is in the source table
81 _injectAttributes() {
82 const newAttributes = {
83 [this.foreignKey]: {
84 type: this.options.keyType || this.target.rawAttributes[this.targetKey].type,
85 allowNull: true,
86 ...this.foreignKeyAttribute
87 }
88 };
89
90 if (this.options.constraints !== false) {
91 const source = this.source.rawAttributes[this.foreignKey] || newAttributes[this.foreignKey];
92 this.options.onDelete = this.options.onDelete || (source.allowNull ? 'SET NULL' : 'NO ACTION');
93 this.options.onUpdate = this.options.onUpdate || 'CASCADE';
94 }
95
96 Helpers.addForeignKeyConstraints(newAttributes[this.foreignKey], this.target, this.source, this.options, this.targetKeyField);
97 Utils.mergeDefaults(this.source.rawAttributes, newAttributes);
98
99 this.source.refreshAttributes();
100
101 this.identifierField = this.source.rawAttributes[this.foreignKey].field || this.foreignKey;
102
103 Helpers.checkNamingCollision(this);
104
105 return this;
106 }
107
108 mixin(obj) {
109 const methods = ['get', 'set', 'create'];

Callers

nothing calls this directly

Calls 1

refreshAttributesMethod · 0.80

Tested by

no test coverage detected