tspace-mysql 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lib/tspace/Model.d.ts +2 -2
- package/dist/lib/tspace/Model.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -640,7 +640,7 @@ hook((result) => ...) // callback result to function
|
|
|
640
640
|
hasOne({ name , model , localKey , foreignKey , freezeTable , as })
|
|
641
641
|
hasMany({ name , model , localKey , foreignKey , freezeTable , as })
|
|
642
642
|
belongsTo({ name , model , localKey , foreignKey , freezeTable , as })
|
|
643
|
-
belongsToMany({ name , model , localKey , foreignKey , freezeTable , as })
|
|
643
|
+
belongsToMany({ name , model , localKey , foreignKey , freezeTable , as , pivot })
|
|
644
644
|
/**
|
|
645
645
|
* @relation using registry in your models
|
|
646
646
|
*/
|
|
@@ -231,7 +231,7 @@ declare class Model extends AbstractModel {
|
|
|
231
231
|
* @property {string} relation.freezeTable
|
|
232
232
|
* @return {this} this
|
|
233
233
|
*/
|
|
234
|
-
protected belongsToMany({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
234
|
+
protected belongsToMany({ name, as, model, localKey, foreignKey, freezeTable, pivot }: Relation): this;
|
|
235
235
|
/**
|
|
236
236
|
* Assign the relation in model Objects
|
|
237
237
|
* @param {object} relation registry relation in your model
|
|
@@ -287,7 +287,7 @@ declare class Model extends AbstractModel {
|
|
|
287
287
|
* @param {function?} callback callback of query
|
|
288
288
|
* @return {this} this
|
|
289
289
|
*/
|
|
290
|
-
protected belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
|
|
290
|
+
protected belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable, pivot }: RelationQuery, callback?: Function): this;
|
|
291
291
|
/**
|
|
292
292
|
* return only in trashed (data has been remove)
|
|
293
293
|
* @return {promise}
|
package/dist/lib/tspace/Model.js
CHANGED
|
@@ -453,7 +453,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
453
453
|
* @property {string} relation.freezeTable
|
|
454
454
|
* @return {this} this
|
|
455
455
|
*/
|
|
456
|
-
belongsToMany({ name, as, model, localKey, foreignKey, freezeTable }) {
|
|
456
|
+
belongsToMany({ name, as, model, localKey, foreignKey, freezeTable, pivot }) {
|
|
457
457
|
const relation = {
|
|
458
458
|
name,
|
|
459
459
|
model,
|
|
@@ -462,6 +462,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
462
462
|
localKey,
|
|
463
463
|
foreignKey,
|
|
464
464
|
freezeTable,
|
|
465
|
+
pivot,
|
|
465
466
|
query: null
|
|
466
467
|
};
|
|
467
468
|
this.$state.set('RELATION', [...this.$state.get('RELATION'), relation]);
|
|
@@ -585,7 +586,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
585
586
|
* @param {function?} callback callback of query
|
|
586
587
|
* @return {this} this
|
|
587
588
|
*/
|
|
588
|
-
belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable }, callback) {
|
|
589
|
+
belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable, pivot }, callback) {
|
|
589
590
|
const nameRelation = name == null
|
|
590
591
|
? this._functionRelationName()
|
|
591
592
|
: String(name);
|
|
@@ -597,6 +598,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
597
598
|
localKey,
|
|
598
599
|
foreignKey,
|
|
599
600
|
freezeTable,
|
|
601
|
+
pivot,
|
|
600
602
|
query: null
|
|
601
603
|
};
|
|
602
604
|
const r = this._handleRelationsQuery(nameRelation, relation);
|
|
@@ -1784,7 +1786,7 @@ class Model extends AbstractModel_1.AbstractModel {
|
|
|
1784
1786
|
_belongsToMany(dataFromParent, relation) {
|
|
1785
1787
|
var _a;
|
|
1786
1788
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1787
|
-
const { name,
|
|
1789
|
+
const { name, foreignKey, pivot } = this._valueInRelation(relation);
|
|
1788
1790
|
const pivotTable = String(((_a = relation.pivot) !== null && _a !== void 0 ? _a : pivot));
|
|
1789
1791
|
const localKeyId = dataFromParent.map((parent) => {
|
|
1790
1792
|
const data = parent[foreignKey];
|