@nocobase/database 1.2.13-alpha → 1.3.0-alpha.20240710084543
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/package.json +4 -4
- package/lib/collection-factory.d.ts +0 -25
- package/lib/collection-factory.js +0 -61
- package/lib/collection-group-manager.d.ts +0 -34
- package/lib/collection-group-manager.js +0 -66
- package/lib/collection-importer.d.ts +0 -15
- package/lib/collection-importer.js +0 -83
- package/lib/collection.d.ts +0 -145
- package/lib/collection.js +0 -663
- package/lib/database-utils/index.d.ts +0 -16
- package/lib/database-utils/index.js +0 -75
- package/lib/database.d.ts +0 -228
- package/lib/database.js +0 -795
- package/lib/decorators/must-have-filter-decorator.d.ts +0 -10
- package/lib/decorators/must-have-filter-decorator.js +0 -48
- package/lib/decorators/target-collection-decorator.d.ts +0 -10
- package/lib/decorators/target-collection-decorator.js +0 -56
- package/lib/decorators/transaction-decorator.d.ts +0 -9
- package/lib/decorators/transaction-decorator.js +0 -95
- package/lib/eager-loading/eager-loading-tree.d.ts +0 -39
- package/lib/eager-loading/eager-loading-tree.js +0 -448
- package/lib/errors/identifier-error.d.ts +0 -11
- package/lib/errors/identifier-error.js +0 -44
- package/lib/errors/zero-column-table-error.d.ts +0 -10
- package/lib/errors/zero-column-table-error.js +0 -40
- package/lib/features/references-map.d.ts +0 -29
- package/lib/features/references-map.js +0 -120
- package/lib/features/referential-integrity-check.d.ts +0 -16
- package/lib/features/referential-integrity-check.js +0 -86
- package/lib/field-repository/array-field-repository.d.ts +0 -36
- package/lib/field-repository/array-field-repository.js +0 -179
- package/lib/fields/array-field.d.ts +0 -19
- package/lib/fields/array-field.js +0 -66
- package/lib/fields/belongs-to-field.d.ts +0 -25
- package/lib/fields/belongs-to-field.js +0 -166
- package/lib/fields/belongs-to-many-field.d.ts +0 -28
- package/lib/fields/belongs-to-many-field.js +0 -196
- package/lib/fields/boolean-field.d.ts +0 -16
- package/lib/fields/boolean-field.js +0 -45
- package/lib/fields/context-field.d.ts +0 -22
- package/lib/fields/context-field.js +0 -79
- package/lib/fields/date-field.d.ts +0 -21
- package/lib/fields/date-field.js +0 -73
- package/lib/fields/field.d.ts +0 -52
- package/lib/fields/field.js +0 -168
- package/lib/fields/has-inverse-field.d.ts +0 -12
- package/lib/fields/has-inverse-field.js +0 -24
- package/lib/fields/has-many-field.d.ts +0 -76
- package/lib/fields/has-many-field.js +0 -165
- package/lib/fields/has-one-field.d.ts +0 -76
- package/lib/fields/has-one-field.js +0 -159
- package/lib/fields/index.d.ts +0 -54
- package/lib/fields/index.js +0 -74
- package/lib/fields/json-field.d.ts +0 -22
- package/lib/fields/json-field.js +0 -63
- package/lib/fields/nanoid-field.d.ts +0 -22
- package/lib/fields/nanoid-field.js +0 -65
- package/lib/fields/number-field.d.ts +0 -49
- package/lib/fields/number-field.js +0 -94
- package/lib/fields/password-field.d.ts +0 -29
- package/lib/fields/password-field.js +0 -106
- package/lib/fields/radio-field.d.ts +0 -24
- package/lib/fields/radio-field.js +0 -75
- package/lib/fields/relation-field.d.ts +0 -31
- package/lib/fields/relation-field.js +0 -94
- package/lib/fields/set-field.d.ts +0 -18
- package/lib/fields/set-field.js +0 -55
- package/lib/fields/sort-field.d.ts +0 -22
- package/lib/fields/sort-field.js +0 -197
- package/lib/fields/string-field.d.ts +0 -16
- package/lib/fields/string-field.js +0 -45
- package/lib/fields/text-field.d.ts +0 -18
- package/lib/fields/text-field.js +0 -53
- package/lib/fields/time-field.d.ts +0 -16
- package/lib/fields/time-field.js +0 -45
- package/lib/fields/uid-field.d.ts +0 -21
- package/lib/fields/uid-field.js +0 -72
- package/lib/fields/uuid-field.d.ts +0 -20
- package/lib/fields/uuid-field.js +0 -63
- package/lib/fields/virtual-field.d.ts +0 -16
- package/lib/fields/virtual-field.js +0 -45
- package/lib/filter-match.d.ts +0 -9
- package/lib/filter-match.js +0 -75
- package/lib/filter-parser.d.ts +0 -29
- package/lib/filter-parser.js +0 -238
- package/lib/helpers.d.ts +0 -11
- package/lib/helpers.js +0 -182
- package/lib/index.d.ts +0 -37
- package/lib/index.js +0 -138
- package/lib/inherited-collection.d.ts +0 -22
- package/lib/inherited-collection.js +0 -147
- package/lib/inherited-map.d.ts +0 -29
- package/lib/inherited-map.js +0 -125
- package/lib/inherited-sync-runner.d.ts +0 -12
- package/lib/inherited-sync-runner.js +0 -184
- package/lib/interface-manager.d.ts +0 -17
- package/lib/interface-manager.js +0 -50
- package/lib/interfaces/base-interface.d.ts +0 -33
- package/lib/interfaces/base-interface.js +0 -80
- package/lib/interfaces/boolean-interface.d.ts +0 -13
- package/lib/interfaces/boolean-interface.js +0 -70
- package/lib/interfaces/checkboxes-interface.d.ts +0 -11
- package/lib/interfaces/checkboxes-interface.js +0 -41
- package/lib/interfaces/datetime-interface.d.ts +0 -13
- package/lib/interfaces/datetime-interface.js +0 -108
- package/lib/interfaces/index.d.ts +0 -14
- package/lib/interfaces/index.js +0 -40
- package/lib/interfaces/integer-interface.d.ts +0 -12
- package/lib/interfaces/integer-interface.js +0 -44
- package/lib/interfaces/json-interface.d.ts +0 -13
- package/lib/interfaces/json-interface.js +0 -47
- package/lib/interfaces/many-to-many-interface.d.ts +0 -11
- package/lib/interfaces/many-to-many-interface.js +0 -41
- package/lib/interfaces/many-to-one-interface.d.ts +0 -11
- package/lib/interfaces/many-to-one-interface.js +0 -41
- package/lib/interfaces/multiple-select-interface.d.ts +0 -13
- package/lib/interfaces/multiple-select-interface.js +0 -76
- package/lib/interfaces/number-interface.d.ts +0 -15
- package/lib/interfaces/number-interface.js +0 -72
- package/lib/interfaces/one-belongs-to-one-interface.d.ts +0 -11
- package/lib/interfaces/one-belongs-to-one-interface.js +0 -41
- package/lib/interfaces/one-has-one-interface.d.ts +0 -11
- package/lib/interfaces/one-has-one-interface.js +0 -41
- package/lib/interfaces/one-to-many-interface.d.ts +0 -11
- package/lib/interfaces/one-to-many-interface.js +0 -41
- package/lib/interfaces/percent-interface.d.ts +0 -13
- package/lib/interfaces/percent-interface.js +0 -55
- package/lib/interfaces/select-interface.d.ts +0 -13
- package/lib/interfaces/select-interface.js +0 -63
- package/lib/interfaces/to-many-interface.d.ts +0 -12
- package/lib/interfaces/to-many-interface.js +0 -61
- package/lib/interfaces/to-one-interface.d.ts +0 -13
- package/lib/interfaces/to-one-interface.js +0 -61
- package/lib/interfaces/utils.d.ts +0 -10
- package/lib/interfaces/utils.js +0 -72
- package/lib/listeners/adjacency-list.d.ts +0 -10
- package/lib/listeners/adjacency-list.js +0 -51
- package/lib/listeners/append-child-collection-name-after-repository-find.d.ts +0 -14
- package/lib/listeners/append-child-collection-name-after-repository-find.js +0 -75
- package/lib/listeners/index.d.ts +0 -10
- package/lib/listeners/index.js +0 -42
- package/lib/magic-attribute-model.d.ts +0 -16
- package/lib/magic-attribute-model.js +0 -213
- package/lib/migration.d.ts +0 -43
- package/lib/migration.js +0 -112
- package/lib/mock-database.d.ts +0 -33
- package/lib/mock-database.js +0 -136
- package/lib/model-hook.d.ts +0 -20
- package/lib/model-hook.js +0 -96
- package/lib/model.d.ts +0 -32
- package/lib/model.js +0 -179
- package/lib/operators/array.d.ts +0 -10
- package/lib/operators/array.js +0 -196
- package/lib/operators/association.d.ts +0 -10
- package/lib/operators/association.js +0 -44
- package/lib/operators/boolean.d.ts +0 -10
- package/lib/operators/boolean.js +0 -47
- package/lib/operators/child-collection.d.ts +0 -10
- package/lib/operators/child-collection.js +0 -77
- package/lib/operators/date.d.ts +0 -10
- package/lib/operators/date.js +0 -149
- package/lib/operators/empty.d.ts +0 -13
- package/lib/operators/empty.js +0 -102
- package/lib/operators/eq.d.ts +0 -10
- package/lib/operators/eq.js +0 -44
- package/lib/operators/index.d.ts +0 -13
- package/lib/operators/index.js +0 -63
- package/lib/operators/ne.d.ts +0 -10
- package/lib/operators/ne.js +0 -49
- package/lib/operators/notIn.d.ts +0 -10
- package/lib/operators/notIn.js +0 -42
- package/lib/operators/string.d.ts +0 -10
- package/lib/operators/string.js +0 -118
- package/lib/operators/utils.d.ts +0 -12
- package/lib/operators/utils.js +0 -53
- package/lib/options-parser.d.ts +0 -45
- package/lib/options-parser.js +0 -350
- package/lib/query-interface/mysql-query-interface.d.ts +0 -44
- package/lib/query-interface/mysql-query-interface.js +0 -134
- package/lib/query-interface/postgres-query-interface.d.ts +0 -41
- package/lib/query-interface/postgres-query-interface.js +0 -207
- package/lib/query-interface/query-interface-builder.d.ts +0 -10
- package/lib/query-interface/query-interface-builder.js +0 -55
- package/lib/query-interface/query-interface.d.ts +0 -52
- package/lib/query-interface/query-interface.js +0 -59
- package/lib/query-interface/sqlite-query-interface.d.ts +0 -44
- package/lib/query-interface/sqlite-query-interface.js +0 -141
- package/lib/relation-repository/belongs-to-many-repository.d.ts +0 -28
- package/lib/relation-repository/belongs-to-many-repository.js +0 -248
- package/lib/relation-repository/belongs-to-repository.d.ts +0 -17
- package/lib/relation-repository/belongs-to-repository.js +0 -51
- package/lib/relation-repository/hasmany-repository.d.ts +0 -21
- package/lib/relation-repository/hasmany-repository.js +0 -158
- package/lib/relation-repository/hasone-repository.d.ts +0 -17
- package/lib/relation-repository/hasone-repository.js +0 -51
- package/lib/relation-repository/multiple-relation-repository.d.ts +0 -27
- package/lib/relation-repository/multiple-relation-repository.js +0 -200
- package/lib/relation-repository/relation-repository.d.ts +0 -38
- package/lib/relation-repository/relation-repository.js +0 -175
- package/lib/relation-repository/single-relation-repository.d.ts +0 -36
- package/lib/relation-repository/single-relation-repository.js +0 -151
- package/lib/relation-repository/types.d.ts +0 -15
- package/lib/relation-repository/types.js +0 -24
- package/lib/repositories/tree-repository/adjacency-list-repository.d.ts +0 -26
- package/lib/repositories/tree-repository/adjacency-list-repository.js +0 -192
- package/lib/repositories/view-repository.d.ts +0 -11
- package/lib/repositories/view-repository.js +0 -41
- package/lib/repository.d.ts +0 -214
- package/lib/repository.js +0 -609
- package/lib/sql-parser/index.d.ts +0 -13
- package/lib/sql-parser/index.js +0 -33
- package/lib/sync-runner.d.ts +0 -41
- package/lib/sync-runner.js +0 -335
- package/lib/types.d.ts +0 -57
- package/lib/types.js +0 -24
- package/lib/update-associations.d.ts +0 -68
- package/lib/update-associations.js +0 -429
- package/lib/update-guard.d.ts +0 -36
- package/lib/update-guard.js +0 -212
- package/lib/utils.d.ts +0 -15
- package/lib/utils.js +0 -136
- package/lib/value-parsers/array-value-parser.d.ts +0 -16
- package/lib/value-parsers/array-value-parser.js +0 -67
- package/lib/value-parsers/base-value-parser.d.ts +0 -20
- package/lib/value-parsers/base-value-parser.js +0 -72
- package/lib/value-parsers/boolean-value-parser.d.ts +0 -12
- package/lib/value-parsers/boolean-value-parser.js +0 -61
- package/lib/value-parsers/date-value-parser.d.ts +0 -13
- package/lib/value-parsers/date-value-parser.js +0 -99
- package/lib/value-parsers/index.d.ts +0 -20
- package/lib/value-parsers/index.js +0 -87
- package/lib/value-parsers/json-value-parser.d.ts +0 -12
- package/lib/value-parsers/json-value-parser.js +0 -56
- package/lib/value-parsers/number-value-parser.d.ts +0 -12
- package/lib/value-parsers/number-value-parser.js +0 -67
- package/lib/value-parsers/string-value-parser.d.ts +0 -16
- package/lib/value-parsers/string-value-parser.js +0 -73
- package/lib/value-parsers/to-many-value-parser.d.ts +0 -21
- package/lib/value-parsers/to-many-value-parser.js +0 -117
- package/lib/value-parsers/to-one-value-parser.d.ts +0 -12
- package/lib/value-parsers/to-one-value-parser.js +0 -57
- package/lib/view/field-type-map.d.ts +0 -109
- package/lib/view/field-type-map.js +0 -101
- package/lib/view/view-inference.d.ts +0 -40
- package/lib/view/view-inference.js +0 -157
- package/lib/view-collection.d.ts +0 -14
- package/lib/view-collection.js +0 -54
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var sqlite_query_interface_exports = {};
|
|
39
|
-
__export(sqlite_query_interface_exports, {
|
|
40
|
-
default: () => SqliteQueryInterface
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(sqlite_query_interface_exports);
|
|
43
|
-
var import_sql_parser = __toESM(require("../sql-parser"));
|
|
44
|
-
var import_query_interface = __toESM(require("./query-interface"));
|
|
45
|
-
/* istanbul ignore file -- @preserve */
|
|
46
|
-
const _SqliteQueryInterface = class _SqliteQueryInterface extends import_query_interface.default {
|
|
47
|
-
constructor(db) {
|
|
48
|
-
super(db);
|
|
49
|
-
}
|
|
50
|
-
async collectionTableExists(collection, options) {
|
|
51
|
-
const transaction = options == null ? void 0 : options.transaction;
|
|
52
|
-
const tableName = collection.model.tableName;
|
|
53
|
-
const sql = `SELECT name
|
|
54
|
-
FROM sqlite_master
|
|
55
|
-
WHERE type = 'table'
|
|
56
|
-
AND name = '${tableName}';`;
|
|
57
|
-
const results = await this.db.sequelize.query(sql, { type: "SELECT", transaction });
|
|
58
|
-
return results.length > 0;
|
|
59
|
-
}
|
|
60
|
-
async listViews() {
|
|
61
|
-
const sql = `
|
|
62
|
-
SELECT name, sql as definition
|
|
63
|
-
FROM sqlite_master
|
|
64
|
-
WHERE type = 'view'
|
|
65
|
-
ORDER BY name;
|
|
66
|
-
`;
|
|
67
|
-
return await this.db.sequelize.query(sql, {
|
|
68
|
-
type: "SELECT"
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
async viewColumnUsage(options) {
|
|
72
|
-
try {
|
|
73
|
-
const { ast } = this.parseSQL(await this.viewDef(options.viewName));
|
|
74
|
-
const columns = ast.columns;
|
|
75
|
-
const results = [];
|
|
76
|
-
for (const column of columns) {
|
|
77
|
-
if (column.expr.type === "column_ref") {
|
|
78
|
-
results.push([
|
|
79
|
-
column.as || column.expr.column,
|
|
80
|
-
{
|
|
81
|
-
column_name: column.expr.column,
|
|
82
|
-
table_name: column.expr.table
|
|
83
|
-
}
|
|
84
|
-
]);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return Object.fromEntries(results);
|
|
88
|
-
} catch (e) {
|
|
89
|
-
this.db.logger.warn(e);
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
parseSQL(sql) {
|
|
94
|
-
return import_sql_parser.default.parse(sql);
|
|
95
|
-
}
|
|
96
|
-
async viewDef(viewName) {
|
|
97
|
-
const viewDefinition = await this.db.sequelize.query(
|
|
98
|
-
`SELECT sql
|
|
99
|
-
FROM sqlite_master
|
|
100
|
-
WHERE name = '${viewName}' AND type = 'view'`,
|
|
101
|
-
{
|
|
102
|
-
type: "SELECT"
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
const createView = viewDefinition[0]["sql"];
|
|
106
|
-
const regex = /(?<=AS\s)([\s\S]*)/i;
|
|
107
|
-
const match = createView.match(regex);
|
|
108
|
-
const sql = match[0];
|
|
109
|
-
return sql;
|
|
110
|
-
}
|
|
111
|
-
showTableDefinition(tableInfo) {
|
|
112
|
-
return Promise.resolve(void 0);
|
|
113
|
-
}
|
|
114
|
-
async getAutoIncrementInfo(options) {
|
|
115
|
-
const { tableInfo, transaction } = options;
|
|
116
|
-
const tableName = tableInfo.tableName;
|
|
117
|
-
const sql = `SELECT seq
|
|
118
|
-
FROM sqlite_sequence
|
|
119
|
-
WHERE name = '${tableName}';`;
|
|
120
|
-
const results = await this.db.sequelize.query(sql, { type: "SELECT", transaction });
|
|
121
|
-
const row = results[0];
|
|
122
|
-
if (!row) {
|
|
123
|
-
return {
|
|
124
|
-
currentVal: 0
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
currentVal: row["seq"]
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
async setAutoIncrementVal(options) {
|
|
132
|
-
const { tableInfo, columnName, seqName, currentVal, transaction } = options;
|
|
133
|
-
const tableName = tableInfo.tableName;
|
|
134
|
-
const sql = `UPDATE sqlite_sequence
|
|
135
|
-
SET seq = ${currentVal}
|
|
136
|
-
WHERE name = '${tableName}';`;
|
|
137
|
-
await this.db.sequelize.query(sql, { transaction });
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
__name(_SqliteQueryInterface, "SqliteQueryInterface");
|
|
141
|
-
let SqliteQueryInterface = _SqliteQueryInterface;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Transaction } from 'sequelize';
|
|
10
|
-
import { AggregateOptions, CreateOptions, DestroyOptions, TargetKey } from '../repository';
|
|
11
|
-
import { MultipleRelationRepository } from './multiple-relation-repository';
|
|
12
|
-
import { AssociatedOptions, PrimaryKeyWithThroughValues } from './types';
|
|
13
|
-
type CreateBelongsToManyOptions = CreateOptions;
|
|
14
|
-
export declare class BelongsToManyRepository extends MultipleRelationRepository {
|
|
15
|
-
aggregate(options: AggregateOptions): Promise<any>;
|
|
16
|
-
create(options?: CreateBelongsToManyOptions): Promise<any>;
|
|
17
|
-
destroy(options?: TargetKey | TargetKey[] | DestroyOptions): Promise<boolean>;
|
|
18
|
-
add(options: TargetKey | TargetKey[] | PrimaryKeyWithThroughValues | PrimaryKeyWithThroughValues[] | AssociatedOptions): Promise<void>;
|
|
19
|
-
set(options: TargetKey | TargetKey[] | PrimaryKeyWithThroughValues | PrimaryKeyWithThroughValues[] | AssociatedOptions): Promise<void>;
|
|
20
|
-
toggle(options: TargetKey | {
|
|
21
|
-
tk?: TargetKey;
|
|
22
|
-
transaction?: Transaction;
|
|
23
|
-
}): Promise<void>;
|
|
24
|
-
throughName(): any;
|
|
25
|
-
throughModel(): any;
|
|
26
|
-
protected setTargets(call: 'add' | 'set', options: TargetKey | TargetKey[] | PrimaryKeyWithThroughValues | PrimaryKeyWithThroughValues[] | AssociatedOptions): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
39
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
40
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
41
|
-
if (decorator = decorators[i])
|
|
42
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
43
|
-
if (kind && result)
|
|
44
|
-
__defProp(target, key, result);
|
|
45
|
-
return result;
|
|
46
|
-
};
|
|
47
|
-
var belongs_to_many_repository_exports = {};
|
|
48
|
-
__export(belongs_to_many_repository_exports, {
|
|
49
|
-
BelongsToManyRepository: () => BelongsToManyRepository
|
|
50
|
-
});
|
|
51
|
-
module.exports = __toCommonJS(belongs_to_many_repository_exports);
|
|
52
|
-
var import_lodash = __toESM(require("lodash"));
|
|
53
|
-
var import_sequelize = require("sequelize");
|
|
54
|
-
var import_update_associations = require("../update-associations");
|
|
55
|
-
var import_multiple_relation_repository = require("./multiple-relation-repository");
|
|
56
|
-
var import_relation_repository = require("./relation-repository");
|
|
57
|
-
const _BelongsToManyRepository = class _BelongsToManyRepository extends import_multiple_relation_repository.MultipleRelationRepository {
|
|
58
|
-
async aggregate(options) {
|
|
59
|
-
const targetRepository = this.targetCollection.repository;
|
|
60
|
-
const sourceModel = await this.getSourceModel();
|
|
61
|
-
const association = this.association;
|
|
62
|
-
return await targetRepository.aggregate({
|
|
63
|
-
...options,
|
|
64
|
-
optionsTransformer: (modelOptions) => {
|
|
65
|
-
modelOptions.include = modelOptions.include || [];
|
|
66
|
-
const throughWhere = {};
|
|
67
|
-
throughWhere[association.foreignKey] = sourceModel.get(association.sourceKey);
|
|
68
|
-
modelOptions.include.push({
|
|
69
|
-
association: association.oneFromTarget,
|
|
70
|
-
required: true,
|
|
71
|
-
attributes: [],
|
|
72
|
-
where: throughWhere
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async create(options) {
|
|
78
|
-
if (Array.isArray(options.values)) {
|
|
79
|
-
return Promise.all(options.values.map((record) => this.create({ ...options, values: record })));
|
|
80
|
-
}
|
|
81
|
-
const transaction2 = await this.getTransaction(options);
|
|
82
|
-
const createAccessor = this.accessors().create;
|
|
83
|
-
const values = options.values || {};
|
|
84
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
85
|
-
const createOptions = {
|
|
86
|
-
...options,
|
|
87
|
-
through: values[this.throughName()],
|
|
88
|
-
transaction: transaction2
|
|
89
|
-
};
|
|
90
|
-
const instance = await sourceModel[createAccessor](values, createOptions);
|
|
91
|
-
await (0, import_update_associations.updateAssociations)(instance, values, { ...options, transaction: transaction2 });
|
|
92
|
-
return instance;
|
|
93
|
-
}
|
|
94
|
-
async destroy(options) {
|
|
95
|
-
const transaction2 = await this.getTransaction(options);
|
|
96
|
-
const association = this.association;
|
|
97
|
-
const throughModel = this.throughModel();
|
|
98
|
-
const instancesToIds = /* @__PURE__ */ __name((instances) => {
|
|
99
|
-
return instances.map((instance) => instance.get(this.targetKey()));
|
|
100
|
-
}, "instancesToIds");
|
|
101
|
-
const throughTableWhere = [
|
|
102
|
-
{
|
|
103
|
-
[throughModel.rawAttributes[association.foreignKey].field]: this.sourceKeyValue
|
|
104
|
-
}
|
|
105
|
-
];
|
|
106
|
-
let ids;
|
|
107
|
-
if (options && options["filter"]) {
|
|
108
|
-
const instances = await this.find({
|
|
109
|
-
filter: options["filter"],
|
|
110
|
-
transaction: transaction2
|
|
111
|
-
});
|
|
112
|
-
ids = instancesToIds(instances);
|
|
113
|
-
}
|
|
114
|
-
if (options && options["filterByTk"]) {
|
|
115
|
-
const instances = this.association.toInstanceArray(options["filterByTk"]);
|
|
116
|
-
ids = ids ? import_lodash.default.intersection(ids, instancesToIds(instances)) : instancesToIds(instances);
|
|
117
|
-
}
|
|
118
|
-
if (options && !options["filterByTk"] && !options["filter"]) {
|
|
119
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
120
|
-
const instances = await sourceModel[this.accessors().get]({
|
|
121
|
-
transaction: transaction2
|
|
122
|
-
});
|
|
123
|
-
ids = instancesToIds(instances);
|
|
124
|
-
}
|
|
125
|
-
throughTableWhere.push({
|
|
126
|
-
[throughModel.rawAttributes[association.otherKey].field]: {
|
|
127
|
-
[import_sequelize.Op.in]: ids
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
await this.throughModel().destroy({
|
|
131
|
-
where: throughTableWhere,
|
|
132
|
-
transaction: transaction2
|
|
133
|
-
});
|
|
134
|
-
await this.targetModel.destroy({
|
|
135
|
-
where: {
|
|
136
|
-
[this.targetKey()]: {
|
|
137
|
-
[import_sequelize.Op.in]: ids
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
transaction: transaction2
|
|
141
|
-
});
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
async add(options) {
|
|
145
|
-
await this.setTargets("add", options);
|
|
146
|
-
}
|
|
147
|
-
async set(options) {
|
|
148
|
-
await this.setTargets("set", options);
|
|
149
|
-
}
|
|
150
|
-
async toggle(options) {
|
|
151
|
-
const transaction2 = await this.getTransaction(options);
|
|
152
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
153
|
-
const has = await sourceModel[this.accessors().hasSingle](options["tk"], {
|
|
154
|
-
transaction: transaction2
|
|
155
|
-
});
|
|
156
|
-
if (has) {
|
|
157
|
-
await this.remove({
|
|
158
|
-
...options,
|
|
159
|
-
transaction: transaction2
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
await this.add({
|
|
163
|
-
...options,
|
|
164
|
-
transaction: transaction2
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
throughName() {
|
|
170
|
-
return this.throughModel().name;
|
|
171
|
-
}
|
|
172
|
-
throughModel() {
|
|
173
|
-
return this.association.through.model;
|
|
174
|
-
}
|
|
175
|
-
async setTargets(call, options) {
|
|
176
|
-
const handleKeys = this.convertTks(options);
|
|
177
|
-
const transaction2 = await this.getTransaction(options, false);
|
|
178
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
179
|
-
const setObj = handleKeys.reduce((carry, item) => {
|
|
180
|
-
if (Array.isArray(item)) {
|
|
181
|
-
carry[item[0]] = item[1];
|
|
182
|
-
} else {
|
|
183
|
-
carry[item] = true;
|
|
184
|
-
}
|
|
185
|
-
return carry;
|
|
186
|
-
}, {});
|
|
187
|
-
const targetKeys = Object.keys(setObj);
|
|
188
|
-
const association = this.association;
|
|
189
|
-
const targetObjects = await this.targetModel.findAll({
|
|
190
|
-
where: {
|
|
191
|
-
[association["targetKey"]]: targetKeys
|
|
192
|
-
},
|
|
193
|
-
transaction: transaction2
|
|
194
|
-
});
|
|
195
|
-
await sourceModel[this.accessors()[call]](targetObjects, {
|
|
196
|
-
transaction: transaction2
|
|
197
|
-
});
|
|
198
|
-
for (const [id, throughValues] of Object.entries(setObj)) {
|
|
199
|
-
if (typeof throughValues === "object") {
|
|
200
|
-
const instance = await this.targetModel.findByPk(id, {
|
|
201
|
-
transaction: transaction2
|
|
202
|
-
});
|
|
203
|
-
await (0, import_update_associations.updateThroughTableValue)(instance, this.throughName(), throughValues, sourceModel, transaction2);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
__name(_BelongsToManyRepository, "BelongsToManyRepository");
|
|
209
|
-
__decorateClass([
|
|
210
|
-
(0, import_relation_repository.transaction)()
|
|
211
|
-
], _BelongsToManyRepository.prototype, "create", 1);
|
|
212
|
-
__decorateClass([
|
|
213
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
214
|
-
return {
|
|
215
|
-
filterByTk: args[0],
|
|
216
|
-
transaction: transaction2
|
|
217
|
-
};
|
|
218
|
-
})
|
|
219
|
-
], _BelongsToManyRepository.prototype, "destroy", 1);
|
|
220
|
-
__decorateClass([
|
|
221
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
222
|
-
return {
|
|
223
|
-
tk: args[0],
|
|
224
|
-
transaction: transaction2
|
|
225
|
-
};
|
|
226
|
-
})
|
|
227
|
-
], _BelongsToManyRepository.prototype, "add", 1);
|
|
228
|
-
__decorateClass([
|
|
229
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
230
|
-
return {
|
|
231
|
-
tk: args[0],
|
|
232
|
-
transaction: transaction2
|
|
233
|
-
};
|
|
234
|
-
})
|
|
235
|
-
], _BelongsToManyRepository.prototype, "set", 1);
|
|
236
|
-
__decorateClass([
|
|
237
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
238
|
-
return {
|
|
239
|
-
tk: args[0],
|
|
240
|
-
transaction: transaction2
|
|
241
|
-
};
|
|
242
|
-
})
|
|
243
|
-
], _BelongsToManyRepository.prototype, "toggle", 1);
|
|
244
|
-
let BelongsToManyRepository = _BelongsToManyRepository;
|
|
245
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
246
|
-
0 && (module.exports = {
|
|
247
|
-
BelongsToManyRepository
|
|
248
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { SingleRelationRepository } from './single-relation-repository';
|
|
10
|
-
export declare class BelongsToRepository extends SingleRelationRepository {
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
filterOptions(sourceModel: any): Promise<{
|
|
15
|
-
[x: number]: any;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var belongs_to_repository_exports = {};
|
|
29
|
-
__export(belongs_to_repository_exports, {
|
|
30
|
-
BelongsToRepository: () => BelongsToRepository
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(belongs_to_repository_exports);
|
|
33
|
-
var import_single_relation_repository = require("./single-relation-repository");
|
|
34
|
-
const _BelongsToRepository = class _BelongsToRepository extends import_single_relation_repository.SingleRelationRepository {
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
async filterOptions(sourceModel) {
|
|
39
|
-
const association = this.association;
|
|
40
|
-
return {
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
[association.targetKey]: sourceModel.get(association.foreignKey)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
__name(_BelongsToRepository, "BelongsToRepository");
|
|
47
|
-
let BelongsToRepository = _BelongsToRepository;
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
BelongsToRepository
|
|
51
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { AggregateOptions, DestroyOptions, FindOptions, TargetKey, TK } from '../repository';
|
|
10
|
-
import { AssociatedOptions, MultipleRelationRepository } from './multiple-relation-repository';
|
|
11
|
-
export declare class HasManyRepository extends MultipleRelationRepository {
|
|
12
|
-
find(options?: FindOptions): Promise<any>;
|
|
13
|
-
aggregate(options: AggregateOptions): Promise<any>;
|
|
14
|
-
destroy(options?: TK | DestroyOptions): Promise<boolean>;
|
|
15
|
-
set(options: TargetKey | TargetKey[] | AssociatedOptions): Promise<void>;
|
|
16
|
-
add(options: TargetKey | TargetKey[] | AssociatedOptions): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
accessors(): import("sequelize").MultiAssociationAccessors;
|
|
21
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
29
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
30
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
31
|
-
if (decorator = decorators[i])
|
|
32
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
33
|
-
if (kind && result)
|
|
34
|
-
__defProp(target, key, result);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
var hasmany_repository_exports = {};
|
|
38
|
-
__export(hasmany_repository_exports, {
|
|
39
|
-
HasManyRepository: () => HasManyRepository
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(hasmany_repository_exports);
|
|
42
|
-
var import_lodash = require("lodash");
|
|
43
|
-
var import_sequelize = require("sequelize");
|
|
44
|
-
var import_multiple_relation_repository = require("./multiple-relation-repository");
|
|
45
|
-
var import_relation_repository = require("./relation-repository");
|
|
46
|
-
const _HasManyRepository = class _HasManyRepository extends import_multiple_relation_repository.MultipleRelationRepository {
|
|
47
|
-
async find(options) {
|
|
48
|
-
const targetRepository = this.targetCollection.repository;
|
|
49
|
-
const addFilter = {
|
|
50
|
-
[this.association.foreignKey]: this.sourceKeyValue
|
|
51
|
-
};
|
|
52
|
-
if (options == null ? void 0 : options.filterByTk) {
|
|
53
|
-
addFilter[this.associationField.targetKey] = options.filterByTk;
|
|
54
|
-
}
|
|
55
|
-
const findOptions = {
|
|
56
|
-
...(0, import_lodash.omit)(options, ["filterByTk", "where", "values", "attributes"]),
|
|
57
|
-
filter: {
|
|
58
|
-
$and: [options.filter || {}, addFilter]
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
return await targetRepository.find(findOptions);
|
|
62
|
-
}
|
|
63
|
-
async aggregate(options) {
|
|
64
|
-
const targetRepository = this.targetCollection.repository;
|
|
65
|
-
const addFilter = {
|
|
66
|
-
[this.association.foreignKey]: this.sourceKeyValue
|
|
67
|
-
};
|
|
68
|
-
const aggOptions = {
|
|
69
|
-
...options,
|
|
70
|
-
filter: {
|
|
71
|
-
$and: [options.filter || {}, addFilter]
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return await targetRepository.aggregate(aggOptions);
|
|
75
|
-
}
|
|
76
|
-
async destroy(options) {
|
|
77
|
-
const transaction2 = await this.getTransaction(options);
|
|
78
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
79
|
-
const where = [
|
|
80
|
-
{
|
|
81
|
-
[this.association.foreignKey]: sourceModel.get(this.association.sourceKey)
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
if (options && options["filter"]) {
|
|
85
|
-
const filterResult = this.parseFilter(options["filter"], options);
|
|
86
|
-
if (filterResult.include && filterResult.include.length > 0) {
|
|
87
|
-
return await this.destroyByFilter(options["filter"], transaction2);
|
|
88
|
-
}
|
|
89
|
-
where.push(filterResult.where);
|
|
90
|
-
}
|
|
91
|
-
if (options && options["filterByTk"]) {
|
|
92
|
-
if (typeof options === "object" && options["filterByTk"]) {
|
|
93
|
-
options = options["filterByTk"];
|
|
94
|
-
}
|
|
95
|
-
where.push({
|
|
96
|
-
[this.targetKey()]: options
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
await this.targetModel.destroy({
|
|
100
|
-
where: {
|
|
101
|
-
[import_sequelize.Op.and]: where
|
|
102
|
-
},
|
|
103
|
-
individualHooks: true,
|
|
104
|
-
transaction: transaction2
|
|
105
|
-
});
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
async set(options) {
|
|
109
|
-
const transaction2 = await this.getTransaction(options);
|
|
110
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
111
|
-
await sourceModel[this.accessors().set](this.convertTks(options), {
|
|
112
|
-
transaction: transaction2
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
async add(options) {
|
|
116
|
-
const transaction2 = await this.getTransaction(options);
|
|
117
|
-
const sourceModel = await this.getSourceModel(transaction2);
|
|
118
|
-
await sourceModel[this.accessors().add](this.convertTks(options), {
|
|
119
|
-
transaction: transaction2
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* @internal
|
|
124
|
-
*/
|
|
125
|
-
accessors() {
|
|
126
|
-
return this.association.accessors;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
__name(_HasManyRepository, "HasManyRepository");
|
|
130
|
-
__decorateClass([
|
|
131
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
132
|
-
return {
|
|
133
|
-
filterByTk: args[0],
|
|
134
|
-
transaction: transaction2
|
|
135
|
-
};
|
|
136
|
-
})
|
|
137
|
-
], _HasManyRepository.prototype, "destroy", 1);
|
|
138
|
-
__decorateClass([
|
|
139
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
140
|
-
return {
|
|
141
|
-
tk: args[0],
|
|
142
|
-
transaction: transaction2
|
|
143
|
-
};
|
|
144
|
-
})
|
|
145
|
-
], _HasManyRepository.prototype, "set", 1);
|
|
146
|
-
__decorateClass([
|
|
147
|
-
(0, import_relation_repository.transaction)((args, transaction2) => {
|
|
148
|
-
return {
|
|
149
|
-
tk: args[0],
|
|
150
|
-
transaction: transaction2
|
|
151
|
-
};
|
|
152
|
-
})
|
|
153
|
-
], _HasManyRepository.prototype, "add", 1);
|
|
154
|
-
let HasManyRepository = _HasManyRepository;
|
|
155
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
-
0 && (module.exports = {
|
|
157
|
-
HasManyRepository
|
|
158
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { SingleRelationRepository } from './single-relation-repository';
|
|
10
|
-
export declare class HasOneRepository extends SingleRelationRepository {
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
filterOptions(sourceModel: any): {
|
|
15
|
-
[x: string]: any;
|
|
16
|
-
};
|
|
17
|
-
}
|