pangea-server 1.0.77 → 1.0.78
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/dist/database/db.class.js +2 -0
- package/dist/database/decorators/columns/general.columns.d.ts +1 -1
- package/dist/database/decorators/columns/general.columns.js +1 -1
- package/dist/database/decorators/relations.d.ts +2 -1
- package/dist/database/decorators/relations.js +2 -2
- package/dist/database/models/base-model.class.d.ts +1 -0
- package/package.json +1 -1
|
@@ -270,6 +270,8 @@ function getInclude(model, config = {}, relDepth = new Map()) {
|
|
|
270
270
|
const maxDepth = rel.joinDepth;
|
|
271
271
|
if (currentDepth >= maxDepth)
|
|
272
272
|
continue;
|
|
273
|
+
if (rel.exclude)
|
|
274
|
+
continue;
|
|
273
275
|
const relWhere = cleanWhere[relName];
|
|
274
276
|
delete cleanWhere[relName];
|
|
275
277
|
const newRelDepth = new Map(relDepth);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ColGeneralOptions, ColVirtualGet, ColVirtualOptions, GetModelFn } from '../../../database/database.types';
|
|
2
2
|
export declare function ColBool(options?: ColGeneralOptions): (target: any, propertyName: string) => void;
|
|
3
|
-
export declare function ColForeignKey(getModelFn: GetModelFn, options?: ColGeneralOptions): (target: any, propertyName: string) => void;
|
|
3
|
+
export declare function ColForeignKey(getModelFn: GetModelFn, options?: Omit<ColGeneralOptions, 'index'>): (target: any, propertyName: string) => void;
|
|
4
4
|
export declare function ColVirtual(options?: ColVirtualOptions | ColVirtualGet): Function;
|
|
@@ -32,7 +32,7 @@ function ColBool(options) {
|
|
|
32
32
|
exports.ColBool = ColBool;
|
|
33
33
|
function ColForeignKey(getModelFn, options) {
|
|
34
34
|
return function (target, propertyName) {
|
|
35
|
-
(0, column_1.Column)('INTEGER', { ...options, onUpdate: 'RESTRICT', onDelete: 'RESTRICT' })(target, propertyName);
|
|
35
|
+
(0, column_1.Column)('INTEGER', { ...options, index: true, onUpdate: 'RESTRICT', onDelete: 'RESTRICT' })(target, propertyName);
|
|
36
36
|
seq.ForeignKey(getModelFn)(target, propertyName);
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { GetModelFn } from '../database.types';
|
|
2
2
|
type RelationOptions = {
|
|
3
|
+
foreignKey?: string;
|
|
4
|
+
exclude?: boolean;
|
|
3
5
|
required?: boolean;
|
|
4
6
|
paranoid?: boolean;
|
|
5
7
|
joinDepth?: number;
|
|
6
|
-
foreignKey?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare const BelongsTo: (getModelFn: GetModelFn, options?: RelationOptions) => (target: any, propertyName: string) => void;
|
|
9
10
|
export declare const HasOne: (getModelFn: GetModelFn, options?: RelationOptions) => (target: any, propertyName: string) => void;
|
|
@@ -35,8 +35,8 @@ function getRelation(relationFn) {
|
|
|
35
35
|
const { foreignKey, ...relOptions } = options;
|
|
36
36
|
relationFn(getModelFn, { as: propertyName, ...(foreignKey && { foreignKey }) })(target, propertyName);
|
|
37
37
|
const model = target.constructor;
|
|
38
|
-
const { required = relationFn === seq.BelongsTo ? !model.Columns[`${propertyName}Id`].allowNull : false, paranoid = relationFn !== seq.BelongsTo, joinDepth = 1, ...restOptions } = relOptions;
|
|
39
|
-
model.AddRelation(propertyName, { getModelFn, required, paranoid, joinDepth, ...restOptions });
|
|
38
|
+
const { exclude = false, required = relationFn === seq.BelongsTo ? !model.Columns[`${propertyName}Id`].allowNull : false, paranoid = relationFn !== seq.BelongsTo, joinDepth = 1, ...restOptions } = relOptions;
|
|
39
|
+
model.AddRelation(propertyName, { getModelFn, exclude, required, paranoid, joinDepth, ...restOptions });
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
}
|