@nocobase/database 0.7.0-alpha.56 → 0.7.0-alpha.59
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/lib/operators/boolean.d.ts +13 -0
- package/lib/operators/boolean.js +35 -0
- package/lib/operators/index.js +1 -1
- package/lib/relation-repository/multiple-relation-repository.d.ts +3 -3
- package/lib/relation-repository/single-relation-repository.d.ts +6 -6
- package/lib/repository.d.ts +4 -7
- package/lib/update-associations.d.ts +1 -2
- package/package.json +3 -3
- package/src/operators/boolean.ts +18 -0
- package/src/operators/index.ts +1 -0
- package/src/relation-repository/multiple-relation-repository.ts +2 -3
- package/src/relation-repository/single-relation-repository.ts +6 -6
- package/src/repository.ts +4 -6
- package/src/update-associations.ts +1 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _sequelize() {
|
|
9
|
+
const data = require("sequelize");
|
|
10
|
+
|
|
11
|
+
_sequelize = function _sequelize() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var _default = {
|
|
19
|
+
$isFalsy() {
|
|
20
|
+
return {
|
|
21
|
+
[_sequelize().Op.or]: {
|
|
22
|
+
[_sequelize().Op.is]: null,
|
|
23
|
+
[_sequelize().Op.eq]: false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
$isTruly() {
|
|
29
|
+
return {
|
|
30
|
+
[_sequelize().Op.eq]: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
};
|
|
35
|
+
exports.default = _default;
|
package/lib/operators/index.js
CHANGED
|
@@ -11,6 +11,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
11
11
|
|
|
12
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
13
|
|
|
14
|
-
var _default = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, require('./association').default), require('./date').default), require('./array').default), require('./empty').default), require('./string').default), require('./ne').default), require('./notIn').default);
|
|
14
|
+
var _default = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, require('./association').default), require('./date').default), require('./array').default), require('./empty').default), require('./string').default), require('./ne').default), require('./notIn').default), require('./boolean').default);
|
|
15
15
|
|
|
16
16
|
exports.default = _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { MultiAssociationAccessors, Transaction } from 'sequelize';
|
|
2
|
-
import { CommonFindOptions, CountOptions, DestroyOptions, Filter, FilterByTk, FindOptions, TargetKey, TK,
|
|
1
|
+
import { MultiAssociationAccessors, Transaction, Transactionable } from 'sequelize';
|
|
2
|
+
import { CommonFindOptions, CountOptions, DestroyOptions, Filter, FilterByTk, FindOptions, TargetKey, TK, UpdateOptions } from '../repository';
|
|
3
3
|
import { RelationRepository } from './relation-repository';
|
|
4
4
|
export interface FindAndCountOptions extends CommonFindOptions {
|
|
5
5
|
}
|
|
6
6
|
export interface FindOneOptions extends CommonFindOptions, FilterByTk {
|
|
7
7
|
}
|
|
8
|
-
export interface AssociatedOptions extends
|
|
8
|
+
export interface AssociatedOptions extends Transactionable {
|
|
9
9
|
tk?: TK;
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class MultipleRelationRepository extends RelationRepository {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { SingleAssociationAccessors } from 'sequelize';
|
|
1
|
+
import { SingleAssociationAccessors, Transactionable } from 'sequelize';
|
|
2
2
|
import { Model } from '../model';
|
|
3
|
-
import { Appends, Except, Fields, Filter, TargetKey,
|
|
3
|
+
import { Appends, Except, Fields, Filter, TargetKey, UpdateOptions } from '../repository';
|
|
4
4
|
import { RelationRepository } from './relation-repository';
|
|
5
|
-
export interface SingleRelationFindOption extends
|
|
5
|
+
export interface SingleRelationFindOption extends Transactionable {
|
|
6
6
|
fields?: Fields;
|
|
7
7
|
except?: Except;
|
|
8
8
|
appends?: Appends;
|
|
9
9
|
filter?: Filter;
|
|
10
10
|
}
|
|
11
|
-
interface SetOption extends
|
|
11
|
+
interface SetOption extends Transactionable {
|
|
12
12
|
tk?: TargetKey;
|
|
13
13
|
}
|
|
14
14
|
export declare abstract class SingleRelationRepository extends RelationRepository {
|
|
15
|
-
remove(options?:
|
|
15
|
+
remove(options?: Transactionable): Promise<void>;
|
|
16
16
|
set(options: TargetKey | SetOption): Promise<void>;
|
|
17
17
|
find(options?: SingleRelationFindOption): Promise<Model<any>>;
|
|
18
18
|
findOne(options?: SingleRelationFindOption): Promise<Model<any>>;
|
|
19
|
-
destroy(options?:
|
|
19
|
+
destroy(options?: Transactionable): Promise<Boolean>;
|
|
20
20
|
update(options: UpdateOptions): Promise<any>;
|
|
21
21
|
accessors(): SingleAssociationAccessors;
|
|
22
22
|
}
|
package/lib/repository.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Association, BulkCreateOptions, CreateOptions as SequelizeCreateOptions, DestroyOptions as SequelizeDestroyOptions, FindAndCountOptions as SequelizeAndCountOptions, FindOptions as SequelizeFindOptions, ModelCtor,
|
|
1
|
+
import { Association, BulkCreateOptions, CreateOptions as SequelizeCreateOptions, DestroyOptions as SequelizeDestroyOptions, FindAndCountOptions as SequelizeAndCountOptions, FindOptions as SequelizeFindOptions, ModelCtor, Transactionable, UpdateOptions as SequelizeUpdateOptions } from 'sequelize';
|
|
2
2
|
import { Collection } from './collection';
|
|
3
3
|
import { Database } from './database';
|
|
4
4
|
import { Model } from './model';
|
|
@@ -12,9 +12,7 @@ export interface IRepository {
|
|
|
12
12
|
interface CreateManyOptions extends BulkCreateOptions {
|
|
13
13
|
records: Values[];
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
transaction?: Transaction;
|
|
17
|
-
}
|
|
15
|
+
export { Transactionable } from 'sequelize';
|
|
18
16
|
export interface FilterAble {
|
|
19
17
|
filter: Filter;
|
|
20
18
|
}
|
|
@@ -29,7 +27,7 @@ export declare type WhiteList = string[];
|
|
|
29
27
|
export declare type BlackList = string[];
|
|
30
28
|
export declare type AssociationKeysToBeUpdate = string[];
|
|
31
29
|
export declare type Values = any;
|
|
32
|
-
export interface CountOptions extends Omit<SequelizeCreateOptions, 'distinct' | 'where' | 'include'>,
|
|
30
|
+
export interface CountOptions extends Omit<SequelizeCreateOptions, 'distinct' | 'where' | 'include'>, Transactionable {
|
|
33
31
|
fields?: Fields;
|
|
34
32
|
filter?: Filter;
|
|
35
33
|
}
|
|
@@ -38,7 +36,7 @@ export interface FilterByTk {
|
|
|
38
36
|
}
|
|
39
37
|
export interface FindOptions extends SequelizeFindOptions, CommonFindOptions, FilterByTk {
|
|
40
38
|
}
|
|
41
|
-
export interface CommonFindOptions extends
|
|
39
|
+
export interface CommonFindOptions extends Transactionable {
|
|
42
40
|
filter?: Filter;
|
|
43
41
|
fields?: Fields;
|
|
44
42
|
appends?: Appends;
|
|
@@ -162,4 +160,3 @@ export declare class Repository<TModelAttributes extends {} = any, TCreationAttr
|
|
|
162
160
|
};
|
|
163
161
|
protected getTransaction(options: any, autoGen?: boolean): Promise<any>;
|
|
164
162
|
}
|
|
165
|
-
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Association, BelongsToMany, Hookable, Transactionable } from 'sequelize';
|
|
2
2
|
import { Model } from './model';
|
|
3
|
-
import { TransactionAble } from './repository';
|
|
4
3
|
export declare function modelAssociations(instance: Model): {
|
|
5
4
|
[key: string]: Association<import("sequelize").Model<any, any>, import("sequelize").Model<any, any>>;
|
|
6
5
|
};
|
|
@@ -9,7 +8,7 @@ export declare function modelAssociationByKey(instance: Model, key: string): Ass
|
|
|
9
8
|
declare type UpdateValue = {
|
|
10
9
|
[key: string]: any;
|
|
11
10
|
};
|
|
12
|
-
interface UpdateOptions extends
|
|
11
|
+
interface UpdateOptions extends Transactionable {
|
|
13
12
|
filter?: any;
|
|
14
13
|
filterByTk?: number | string;
|
|
15
14
|
whitelist?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.59",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@nocobase/utils": "0.7.0-alpha.
|
|
15
|
+
"@nocobase/utils": "0.7.0-alpha.59",
|
|
16
16
|
"async-mutex": "^0.3.2",
|
|
17
17
|
"deepmerge": "^4.2.2",
|
|
18
18
|
"flat": "^5.0.2",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
25
25
|
"directory": "packages/database"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "c90e5aee4c8257a3ab7ff492e69cb568cccff8b5"
|
|
28
28
|
}
|
package/src/operators/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { omit } from 'lodash';
|
|
2
|
-
import { MultiAssociationAccessors, Op, Sequelize, Transaction } from 'sequelize';
|
|
2
|
+
import { MultiAssociationAccessors, Op, Sequelize, Transaction, Transactionable } from 'sequelize';
|
|
3
3
|
import {
|
|
4
4
|
CommonFindOptions,
|
|
5
5
|
CountOptions,
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
FindOptions,
|
|
10
10
|
TargetKey,
|
|
11
11
|
TK,
|
|
12
|
-
TransactionAble,
|
|
13
12
|
UpdateOptions
|
|
14
13
|
} from '../repository';
|
|
15
14
|
import { updateModelByValues } from '../update-associations';
|
|
@@ -20,7 +19,7 @@ export interface FindAndCountOptions extends CommonFindOptions {}
|
|
|
20
19
|
|
|
21
20
|
export interface FindOneOptions extends CommonFindOptions, FilterByTk {}
|
|
22
21
|
|
|
23
|
-
export interface AssociatedOptions extends
|
|
22
|
+
export interface AssociatedOptions extends Transactionable {
|
|
24
23
|
tk?: TK;
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import lodash from 'lodash';
|
|
2
|
-
import { SingleAssociationAccessors } from 'sequelize';
|
|
2
|
+
import { SingleAssociationAccessors, Transactionable } from 'sequelize';
|
|
3
3
|
import { Model } from '../model';
|
|
4
|
-
import { Appends, Except, Fields, Filter, TargetKey,
|
|
4
|
+
import { Appends, Except, Fields, Filter, TargetKey, UpdateOptions } from '../repository';
|
|
5
5
|
import { updateModelByValues } from '../update-associations';
|
|
6
6
|
import { RelationRepository, transaction } from './relation-repository';
|
|
7
7
|
|
|
8
|
-
export interface SingleRelationFindOption extends
|
|
8
|
+
export interface SingleRelationFindOption extends Transactionable {
|
|
9
9
|
fields?: Fields;
|
|
10
10
|
except?: Except;
|
|
11
11
|
appends?: Appends;
|
|
12
12
|
filter?: Filter;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
interface SetOption extends
|
|
15
|
+
interface SetOption extends Transactionable {
|
|
16
16
|
tk?: TargetKey;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export abstract class SingleRelationRepository extends RelationRepository {
|
|
20
20
|
@transaction()
|
|
21
|
-
async remove(options?:
|
|
21
|
+
async remove(options?: Transactionable): Promise<void> {
|
|
22
22
|
const transaction = await this.getTransaction(options);
|
|
23
23
|
const sourceModel = await this.getSourceModel(transaction);
|
|
24
24
|
return await sourceModel[this.accessors().set](null, {
|
|
@@ -63,7 +63,7 @@ export abstract class SingleRelationRepository extends RelationRepository {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
@transaction()
|
|
66
|
-
async destroy(options?:
|
|
66
|
+
async destroy(options?: Transactionable): Promise<Boolean> {
|
|
67
67
|
const transaction = await this.getTransaction(options);
|
|
68
68
|
|
|
69
69
|
const target = await this.find({
|
package/src/repository.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
FindOptions as SequelizeFindOptions,
|
|
9
9
|
ModelCtor,
|
|
10
10
|
Op,
|
|
11
|
-
|
|
11
|
+
Transactionable,
|
|
12
12
|
UpdateOptions as SequelizeUpdateOptions
|
|
13
13
|
} from 'sequelize';
|
|
14
14
|
import { Collection } from './collection';
|
|
@@ -34,9 +34,7 @@ interface CreateManyOptions extends BulkCreateOptions {
|
|
|
34
34
|
records: Values[];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export
|
|
38
|
-
transaction?: Transaction;
|
|
39
|
-
}
|
|
37
|
+
export { Transactionable } from 'sequelize';
|
|
40
38
|
|
|
41
39
|
export interface FilterAble {
|
|
42
40
|
filter: Filter;
|
|
@@ -57,7 +55,7 @@ export type AssociationKeysToBeUpdate = string[];
|
|
|
57
55
|
|
|
58
56
|
export type Values = any;
|
|
59
57
|
|
|
60
|
-
export interface CountOptions extends Omit<SequelizeCreateOptions, 'distinct' | 'where' | 'include'>,
|
|
58
|
+
export interface CountOptions extends Omit<SequelizeCreateOptions, 'distinct' | 'where' | 'include'>, Transactionable {
|
|
61
59
|
fields?: Fields;
|
|
62
60
|
filter?: Filter;
|
|
63
61
|
}
|
|
@@ -68,7 +66,7 @@ export interface FilterByTk {
|
|
|
68
66
|
|
|
69
67
|
export interface FindOptions extends SequelizeFindOptions, CommonFindOptions, FilterByTk {}
|
|
70
68
|
|
|
71
|
-
export interface CommonFindOptions extends
|
|
69
|
+
export interface CommonFindOptions extends Transactionable {
|
|
72
70
|
filter?: Filter;
|
|
73
71
|
fields?: Fields;
|
|
74
72
|
appends?: Appends;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
Transactionable,
|
|
10
10
|
} from 'sequelize';
|
|
11
11
|
import { Model } from './model';
|
|
12
|
-
import { TransactionAble } from './repository';
|
|
13
12
|
import { UpdateGuard } from './update-guard';
|
|
14
13
|
|
|
15
14
|
function isUndefinedOrNull(value: any) {
|
|
@@ -46,7 +45,7 @@ export function modelAssociationByKey(instance: Model, key: string): Association
|
|
|
46
45
|
|
|
47
46
|
type UpdateValue = { [key: string]: any };
|
|
48
47
|
|
|
49
|
-
interface UpdateOptions extends
|
|
48
|
+
interface UpdateOptions extends Transactionable {
|
|
50
49
|
filter?: any;
|
|
51
50
|
filterByTk?: number | string;
|
|
52
51
|
// 字段白名单
|