@cloudcome/utils-uni 1.13.0 → 1.14.0

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.
@@ -0,0 +1,15 @@
1
+ export declare class DbBaseCommand {
2
+ command: string;
3
+ parameter: unknown;
4
+ constructor(command: string, parameter: unknown);
5
+ getValue(db: UniCloud.Database): unknown;
6
+ getExpression(fieldName: string): {
7
+ [x: string]: unknown[];
8
+ };
9
+ }
10
+ export declare class DbQueryCommand extends DbBaseCommand {
11
+ isQueryCommand: boolean;
12
+ }
13
+ export declare class DbMutateCommand extends DbBaseCommand {
14
+ isMutateCommand: boolean;
15
+ }
@@ -1,7 +1,7 @@
1
1
  import { AnyObject, Exact, HasProperty, IsEmptyObject, IsOnlyProperty, MergeIntersection } from '@cloudcome/utils-core/types';
2
- import { DatabaseMutateCommand, DatabaseQueryCommand } from './types';
2
+ import { DbMutateCommand, DbQueryCommand } from './_command.class';
3
3
  export type DbWhere<T> = {
4
- [K in keyof T]?: T[K] | DatabaseQueryCommand;
4
+ [K in keyof T]?: T[K] | DbQueryCommand;
5
5
  };
6
6
  export type DbSelect<T> = {
7
7
  [K in keyof T]?: K extends '_id' ? boolean : true;
@@ -9,21 +9,21 @@ export type DbSelect<T> = {
9
9
  export type DbFieldsDefault<T> = {
10
10
  [K in keyof T]: true;
11
11
  };
12
- type _OnlyFieldId<T, V> = IsOnlyProperty<T, '_id'> extends true ? '_id' extends keyof T ? T['_id'] extends V ? true : false : false : false;
13
- type _DbFields<T, S extends DbSelect<T>> = IsEmptyObject<S> extends true ? DbFieldsDefault<T> : _OnlyFieldId<S, false> extends true ? Omit<DbFieldsDefault<T>, '_id'> : _OnlyFieldId<S, true> extends true ? {
12
+ type _OnlyFieldId<D, V> = IsOnlyProperty<D, '_id'> extends true ? '_id' extends keyof D ? D['_id'] extends V ? true : false : false : false;
13
+ type _DbFields<D, S extends DbSelect<D>> = IsEmptyObject<S> extends true ? DbFieldsDefault<D> : _OnlyFieldId<S, false> extends true ? Omit<DbFieldsDefault<D>, '_id'> : _OnlyFieldId<S, true> extends true ? {
14
14
  _id: true;
15
15
  } : HasProperty<S, '_id'> extends true ? S : // 没有的话补上 {_id, ...}
16
16
  S & {
17
17
  _id: true;
18
18
  };
19
- type _DbQuery<T, S extends Record<keyof T, boolean>> = {
20
- [K in keyof T as S[K] extends true ? K : never]: T[K];
19
+ type _DbQuery<D1, S1 extends DbSelect<D1>> = {
20
+ [K in keyof D1 as S1[K] extends true ? K : never]: D1[K];
21
21
  };
22
- export type DbQuery<T, S extends DbSelect<T>, R> = _DbQuery<T, _DbFields<T, S>> & R;
23
- export type DbForeign<T, S extends DbSelect<T>, R, J extends DbJoinType, A> = Record<A & string, J extends '1:1' ? DbQuery<T, S, R> : DbQuery<T, S, R>[]>;
22
+ export type DbQuery<D1, S1 extends DbSelect<D1>, D2> = _DbQuery<D1, _DbFields<D1, S1>> & D2;
23
+ export type DbForeign<D1, S1 extends DbSelect<D1>, D2, JT extends DbJoinType, AS extends string> = Record<AS, JT extends '1:1' ? DbQuery<D1, S1, D2> : DbQuery<D1, S1, D2>[]>;
24
24
  export type DbCreate<T> = Partial<T>;
25
25
  export type DbUpdate<T> = {
26
- [K in keyof T]?: T[K] | DatabaseMutateCommand;
26
+ [K in keyof T]?: T[K] | DbMutateCommand;
27
27
  };
28
28
  export type DbOrder<T> = Record<keyof T, 'asc' | 'desc'>;
29
29
  export type DbOptions = {
@@ -47,52 +47,50 @@ export type DbOptions = {
47
47
  * - 'n:1': 多对一关联,返回值 n 个
48
48
  */
49
49
  export type DbJoinType = '1:1' | '1:n' | 'n:1';
50
- export type DbLookupOptions<J extends DbJoinType, L, F, A> = {
50
+ export type DbLookupOptions<JT extends DbJoinType, D1, FD1, AS, US extends boolean | undefined | void = undefined> = {
51
51
  /**
52
52
  * 关联类型
53
53
  */
54
- type: J;
54
+ type: JT;
55
55
  /**
56
56
  * 主表字段
57
57
  */
58
- localField: keyof L & string;
58
+ localField: keyof D1 & string;
59
59
  /**
60
60
  * 关联表字段
61
61
  */
62
- foreignField: keyof F & string;
62
+ foreignField: keyof FD1 & string;
63
63
  /**
64
64
  * 关联数据在结果中的字段名
65
65
  */
66
- as: A;
66
+ as: AS;
67
+ /**
68
+ * 是否取消筛选关联数据
69
+ */
70
+ unselect?: US;
67
71
  };
68
- export type DbLookup = {
72
+ export type DbLookup = DbLookupOptions<any, unknown, unknown, string, boolean> & {
69
73
  /**
70
74
  * 关联表
71
75
  */
72
76
  table: Db<unknown>;
77
+ };
78
+ /**
79
+ * 数据库类
80
+ * @template D1 - 主表数据
81
+ * @template S1 - 主表筛选
82
+ * @template D2 - 副表数据
83
+ * @template W2 - 副表查询
84
+ */
85
+ export declare class Db<D1, S1 extends DbSelect<D1> = {}, D2 extends AnyObject = {}, W2 extends AnyObject = {}> {
86
+ private _host;
73
87
  /**
74
- * 关联类型
75
- */
76
- type: DbJoinType;
77
- /**
78
- * 主表字段
79
- */
80
- localField: string;
81
- /**
82
- * 关联表字段
83
- */
84
- foreignField: string;
85
- /**
86
- * 关联表名称
87
- */
88
- from: string;
89
- /**
90
- * 关联数据在结果中的字段名
88
+ * 是否为事务环境
89
+ * - 查询条件只能是 id
90
+ * - 不能聚合操作
91
91
  */
92
- as: string;
93
- };
94
- export declare class Db<T, S extends DbSelect<T> = {}, R extends AnyObject = {}> {
95
- #private;
92
+ private _isTransaction;
93
+ private _options;
96
94
  /**
97
95
  * 构造函数,初始化数据库集合引用
98
96
  * @param collection 数据表名称
@@ -105,57 +103,74 @@ export declare class Db<T, S extends DbSelect<T> = {}, R extends AnyObject = {}>
105
103
  * @returns 聚合操作实例
106
104
  */
107
105
  aggregate(): UniCloud.AggregateReference;
106
+ private _hasWhere;
107
+ private _hasWhereId;
108
+ private _where;
109
+ private _doWhere;
108
110
  /**
109
111
  * 设置查询条件
110
112
  * @param where 查询条件对象
111
113
  * @returns 当前Db实例,支持链式调用
112
114
  */
113
- where(where: DbWhere<T>): this;
115
+ where(where: DbWhere<D1> & W2): this;
114
116
  /**
115
117
  * 根据ID设置查询条件
116
118
  * @param id 记录ID
117
119
  * @returns 当前Db实例,支持链式调用
118
120
  */
119
121
  whereId(id: string | number): this;
122
+ private _hasSelect;
123
+ private _select;
120
124
  /**
121
125
  * 指定要返回的字段
122
126
  * @param fields 要返回的字段对象,true表示返回,false表示不返回
123
127
  * @returns 当前Db实例,支持链式调用
124
128
  */
125
- select<U extends DbSelect<T>>(fields: Exact<U, DbSelect<T>>): Db<T, S & U, R>;
129
+ select<S extends DbSelect<D1>>(fields: Exact<S, DbSelect<D1>>): this;
130
+ private _hasOrder;
131
+ private _order;
126
132
  /**
127
133
  * 设置排序规则
128
134
  * @param order 排序规则对象,key为字段名,value为"asc"或"desc"
129
135
  * @returns 当前Db实例,支持链式调用
130
136
  */
131
- order(order: DbOrder<T>): this;
137
+ order(order: DbOrder<D1>): this;
138
+ private _hasSkip;
139
+ private _skip;
132
140
  /**
133
141
  * 跳过指定数量的记录
134
142
  * @param skip 要跳过的记录数
135
143
  * @returns 当前Db实例,支持链式调用
136
144
  */
137
145
  skip(skip: number): this;
146
+ private _hasLimit;
147
+ private _limit;
138
148
  /**
139
149
  * 限制返回的记录数量
140
150
  * @param limit 最大返回记录数
141
151
  * @returns 当前Db实例,支持链式调用
142
152
  */
143
153
  limit(limit: number): this;
154
+ private _hasLookup;
144
155
  get hasLookup(): boolean;
145
- lookup<FT, FS extends DbSelect<FT>, FR extends AnyObject, J extends DbJoinType, A extends string>(table: Db<FT, FS, FR>, lookup: DbLookupOptions<J, T, FT, A>): Db<T, S, MergeIntersection<R & DbForeign<FT, FS, FR, J, A>>>;
156
+ private _lookups;
157
+ lookup<FD1, FS1 extends DbSelect<FD1>, FD2 extends AnyObject, FW2 extends AnyObject, JT extends DbJoinType, AS extends string, US extends boolean | undefined | void = undefined>(table: Db<FD1, FS1, FD2, FW2>, lookup: DbLookupOptions<JT, D1, FD1, AS, US>): Db<D1, S1, US extends true ? D2 : MergeIntersection<D2 & DbForeign<FD1, FS1, FD2, JT, AS>>, MergeIntersection<W2 & Partial<Record<AS, DbQueryCommand>>>>;
158
+ private _aggregated;
159
+ private _endAggregate;
160
+ private _endHost;
146
161
  /**
147
162
  * 执行查询操作
148
163
  * @returns 查询结果
149
164
  */
150
- query(): Promise<DbQuery<T, S, R>[]>;
165
+ query(): Promise<DbQuery<D1, S1, D2>[]>;
151
166
  /**
152
167
  * 只查询一条,自动添加 limit(1) 条件
153
- * @param ignoreMiss 是否忽略没有匹配到记录
168
+ * @param allowMiss 是否允许没有匹配到记录,如果为 true,则可能返回 undefined
154
169
  * @returns 查询结果
155
170
  */
156
- queryOne(): Promise<DbQuery<T, S, R>>;
157
- queryOne(ignoreMiss: false): Promise<DbQuery<T, S, R>>;
158
- queryOne(ignoreMiss: true): Promise<DbQuery<T, S, R> | undefined>;
171
+ queryOne(): Promise<DbQuery<D1, S1, D2>>;
172
+ queryOne(allowMiss: false): Promise<DbQuery<D1, S1, D2>>;
173
+ queryOne(allowMiss: true): Promise<DbQuery<D1, S1, D2> | undefined>;
159
174
  /**
160
175
  * 获取匹配记录的数量
161
176
  * @returns 记录总数
@@ -166,7 +181,7 @@ export declare class Db<T, S extends DbSelect<T> = {}, R extends AnyObject = {}>
166
181
  * @param data 要创建的数据
167
182
  * @returns 创建结果
168
183
  */
169
- create(data: DbCreate<T>): Promise<string>;
184
+ create(data: DbCreate<D1>): Promise<string>;
170
185
  /**
171
186
  * 更新记录
172
187
  * @param data 要更新的数据
@@ -1,13 +1,122 @@
1
- import { DatabaseCommand } from './types';
1
+ import { DbMutateCommand, DbQueryCommand } from './_command.class';
2
2
  /**
3
- * 数据库操作符命令
3
+ * 数据库查询命令对象,提供各种查询操作符
4
4
  */
5
- export declare const dbCmd: DatabaseCommand;
5
+ export declare const dbQuery: {
6
+ /**
7
+ * 等于操作符
8
+ * @param value 比较值
9
+ * @returns DbQueryCommand 查询命令对象
10
+ */
11
+ eq: (value: unknown) => DbQueryCommand;
12
+ /**
13
+ * 不等于操作符
14
+ * @param value 比较值
15
+ * @returns DbQueryCommand 查询命令对象
16
+ */
17
+ neq: (value: unknown) => DbQueryCommand;
18
+ /**
19
+ * 大于操作符
20
+ * @param value 比较值
21
+ * @returns DbQueryCommand 查询命令对象
22
+ */
23
+ gt: (value: unknown) => DbQueryCommand;
24
+ /**
25
+ * 大于等于操作符
26
+ * @param value 比较值
27
+ * @returns DbQueryCommand 查询命令对象
28
+ */
29
+ gte: (value: unknown) => DbQueryCommand;
30
+ /**
31
+ * 小于操作符
32
+ * @param value 比较值
33
+ * @returns DbQueryCommand 查询命令对象
34
+ */
35
+ lt: (value: unknown) => DbQueryCommand;
36
+ /**
37
+ * 小于等于操作符
38
+ * @param value 比较值
39
+ * @returns DbQueryCommand 查询命令对象
40
+ */
41
+ lte: (value: unknown) => DbQueryCommand;
42
+ /**
43
+ * 包含在数组中操作符
44
+ * @param value 值数组
45
+ * @returns DbQueryCommand 查询命令对象
46
+ */
47
+ in: (value: unknown[]) => DbQueryCommand;
48
+ /**
49
+ * 不包含在数组中操作符
50
+ * @param value 值数组
51
+ * @returns DbQueryCommand 查询命令对象
52
+ */
53
+ nin: (value: unknown[]) => DbQueryCommand;
54
+ /**
55
+ * 逻辑与操作符
56
+ * @param conditions 查询条件参数
57
+ * @returns DbQueryCommand 查询命令对象
58
+ */
59
+ and: (conditions: unknown[]) => DbQueryCommand;
60
+ /**
61
+ * 逻辑或操作符
62
+ * @param conditions 查询条件参数
63
+ * @returns DbQueryCommand 查询命令对象
64
+ */
65
+ or: (conditions: unknown[]) => DbQueryCommand;
66
+ /**
67
+ * 数组长度匹配操作符
68
+ * @param size 数组长度
69
+ * @returns DbQueryCommand 查询命令对象
70
+ */
71
+ size: (size: number) => DbQueryCommand;
72
+ };
6
73
  /**
7
- * 数据库聚合操作符命令
74
+ * 数据库变更命令对象,提供各种数据更新操作符
8
75
  */
9
- export declare const dbAgg: UniCloud.AggregateCommand & {
10
- pipeline: () => UniCloud.AggregateReference & {
11
- done: () => unknown;
12
- };
76
+ export declare const dbMutate: {
77
+ /**
78
+ * 数值增加操作符
79
+ * @param value 增加的数值
80
+ * @returns DbMutateCommand 变更命令对象
81
+ */
82
+ inc: (value: number) => DbMutateCommand;
83
+ /**
84
+ * 数值乘法操作符
85
+ * @param value 乘数
86
+ * @returns DbMutateCommand 变更命令对象
87
+ */
88
+ mul: (value: number) => DbMutateCommand;
89
+ /**
90
+ * 设置字段值操作符
91
+ * @param value 设置的值
92
+ * @returns DbMutateCommand 变更命令对象
93
+ */
94
+ set: (value: unknown) => DbMutateCommand;
95
+ /**
96
+ * 向数组末尾添加元素操作符
97
+ * @param value 添加的值
98
+ * @returns DbMutateCommand 变更命令对象
99
+ */
100
+ push: (value: unknown) => DbMutateCommand;
101
+ /**
102
+ * 向数组开头添加元素操作符
103
+ * @param value 添加的值
104
+ * @returns DbMutateCommand 变更命令对象
105
+ */
106
+ unshift: (value: unknown) => DbMutateCommand;
107
+ /**
108
+ * 从数组末尾移除元素操作符
109
+ * @returns DbMutateCommand 变更命令对象
110
+ */
111
+ pop: () => DbMutateCommand;
112
+ /**
113
+ * 从数组开头移除元素操作符
114
+ * @returns DbMutateCommand 变更命令对象
115
+ */
116
+ shift: () => DbMutateCommand;
117
+ /**
118
+ * 移除字段操作符
119
+ * @returns DbMutateCommand 变更命令对象
120
+ */
121
+ remove: () => DbMutateCommand;
13
122
  };
@@ -1,20 +1,17 @@
1
- import { AnyObject } from '@cloudcome/utils-core/types';
2
- import { Db, DbSelect } from './db.class';
1
+ import { Db, DbSelect } from './_db.class';
3
2
  /**
4
3
  * DbProxy 类型定义,用于创建数据库代理对象
5
- * @template T - 数据库表的类型
6
- * @template S - 数据库选择器类型,默认为空对象
7
- * @template R - 数据库返回结果类型,默认为空对象
4
+ * @template D1 - 主表数据
5
+ * @template S1 - 主表筛选
8
6
  */
9
- export type DbProxy<T, S extends DbSelect<T> = {}, R extends AnyObject = {}> = Db<T, S, R> & {
7
+ export type DbProxy<D1, S1 extends DbSelect<D1> = {}> = Db<D1, S1> & {
10
8
  _isProxy: true;
11
9
  };
12
10
  /**
13
11
  * 创建一个数据库代理对象,用于延迟实例化数据库操作类
14
- * @template T - 数据库表的类型
15
- * @template S - 数据库选择器类型,默认为空对象
16
- * @template R - 数据库返回结果类型,默认为空对象
12
+ * @template D1 - 主表数据
13
+ * @template S1 - 主表筛选
17
14
  * @param name - 数据库表名
18
15
  * @returns 返回一个代理对象,该对象会将属性访问转发到实际的数据库操作实例
19
16
  */
20
- export declare function dbProxy<T, S extends DbSelect<T> = {}, R extends AnyObject = {}>(name: string): DbProxy<T>;
17
+ export declare function dbProxy<D1, S1 extends DbSelect<D1> = {}>(name: string): DbProxy<D1, S1>;
@@ -1,11 +1,10 @@
1
- import { AnyObject } from '@cloudcome/utils-core/types';
2
- import { Db, DbSelect } from './db.class';
1
+ import { Db } from './_db.class';
3
2
  import { DbProxy } from './proxy';
4
- type _WithTransaction = <T, S extends DbSelect<T>, R extends AnyObject>(table: DbProxy<T, S, R>) => Db<T, S, R>;
3
+ type _WithTransaction = <D1>(table: DbProxy<D1>) => Db<D1>;
5
4
  /**
6
5
  * 在数据库事务中执行操作
7
6
  *
8
- * @template T - 事务操作返回值类型
7
+ * @template K - 事务操作返回值类型
9
8
  * @param transacting - 事务执行函数,接收事务数据库实例作为参数
10
9
  * @param _mockDatabase - 用于测试的模拟数据库对象
11
10
  * @param _mockDbInstance - 用于测试的模拟数据库实例
@@ -7,144 +7,3 @@ export type ClientDatabaseOutput<T> = {
7
7
  };
8
8
  };
9
9
  export type CloudDatabaseOutput<T> = T;
10
- export type DatabaseQueryCommand = {
11
- _: never;
12
- };
13
- export type DatabaseMutateCommand = {
14
- _: never;
15
- };
16
- /**
17
- * DatabaseCommand 数据库操作命令类型定义
18
- */
19
- export type DatabaseCommand = {
20
- /**
21
- * 聚合表达式操作符
22
- * @param expr 表达式参数
23
- * @returns 返回聚合表达式结果
24
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-expr expr 文档}
25
- */
26
- expr: (expr: unknown) => DatabaseQueryCommand;
27
- /**
28
- * 等于操作符
29
- * @param value 比较值
30
- * @returns 返回查询条件
31
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-eq eq 文档}
32
- */
33
- eq: (value: unknown) => DatabaseQueryCommand;
34
- /**
35
- * 不等于操作符
36
- * @param value 比较值
37
- * @returns 返回查询条件
38
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-neq neq 文档}
39
- */
40
- neq: (value: unknown) => DatabaseQueryCommand;
41
- /**
42
- * 大于操作符
43
- * @param value 比较值
44
- * @returns 返回查询条件
45
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-gt gt 文档}
46
- */
47
- gt: (value: unknown) => DatabaseQueryCommand;
48
- /**
49
- * 大于等于操作符
50
- * @param value 比较值
51
- * @returns 返回查询条件
52
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-gte gte 文档}
53
- */
54
- gte: (value: unknown) => DatabaseQueryCommand;
55
- /**
56
- * 小于操作符
57
- * @param value 比较值
58
- * @returns 返回查询条件
59
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-lt lt 文档}
60
- */
61
- lt: (value: unknown) => DatabaseQueryCommand;
62
- /**
63
- * 小于等于操作符
64
- * @param value 比较值
65
- * @returns 返回查询条件
66
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-lte lte 文档}
67
- */
68
- lte: (value: unknown) => DatabaseQueryCommand;
69
- /**
70
- * 包含在数组内操作符
71
- * @param value 包含的值数组
72
- * @returns 返回查询条件
73
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-in in 文档}
74
- */
75
- in: (value: unknown[]) => DatabaseQueryCommand;
76
- /**
77
- * 不包含在数组内操作符
78
- * @param value 不包含的值数组
79
- * @returns 返回查询条件
80
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-nin nin 文档}
81
- */
82
- nin: (value: unknown[]) => DatabaseQueryCommand;
83
- /**
84
- * 逻辑与操作符
85
- * @param args 多个查询条件
86
- * @returns 返回逻辑与查询条件
87
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-and and 文档}
88
- */
89
- and: (...args: unknown[]) => DatabaseQueryCommand;
90
- /**
91
- * 逻辑或操作符
92
- * @param args 多个查询条件
93
- * @returns 返回逻辑或查询条件
94
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#dbcmd-or or 文档}
95
- */
96
- or: (...args: unknown[]) => DatabaseQueryCommand;
97
- /**
98
- * 自增操作符
99
- * @param value 增加的数值
100
- * @returns 返回更新操作
101
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-inc inc 文档}
102
- */
103
- inc: (value: number) => DatabaseMutateCommand;
104
- /**
105
- * 自乘操作符
106
- * @param value 相乘的数值
107
- * @returns 返回更新操作
108
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-mul mul 文档}
109
- */
110
- mul: (value: number) => DatabaseMutateCommand;
111
- /**
112
- * 设置字段值操作符
113
- * @param value 设置的值
114
- * @returns 返回更新操作
115
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-set set 文档}
116
- */
117
- set: (value: unknown) => DatabaseMutateCommand;
118
- /**
119
- * 数组末尾添加元素操作符
120
- * @param value 添加的值
121
- * @returns 返回更新操作
122
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-push push 文档}
123
- */
124
- push: (value: unknown) => DatabaseMutateCommand;
125
- /**
126
- * 数组开头添加元素操作符
127
- * @param value 添加的值
128
- * @returns 返回更新操作
129
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-unshift unshift 文档}
130
- */
131
- unshift: (value: unknown) => DatabaseMutateCommand;
132
- /**
133
- * 删除数组末尾元素操作符
134
- * @returns 返回更新操作
135
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-pop pop 文档}
136
- */
137
- pop: () => DatabaseMutateCommand;
138
- /**
139
- * 删除数组开头元素操作符
140
- * @returns 返回更新操作
141
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-shift shift 文档}
142
- */
143
- shift: () => DatabaseMutateCommand;
144
- /**
145
- * 删除字段操作符
146
- * @returns 返回更新操作
147
- * @see {@link https://doc.dcloud.net.cn/uniCloud/cf-database.html#operator-remove remove 文档}
148
- */
149
- remove: () => DatabaseMutateCommand;
150
- };
@@ -1,4 +1,4 @@
1
- import { DbCreate, DbSelect, DbUpdate, DbWhere } from './db.class';
1
+ import { DbCreate, DbSelect, DbUpdate, DbWhere } from './_db.class';
2
2
  import { DbProxy } from './proxy';
3
3
  export type DbUniqueOptions<T, S extends DbSelect<T>, C extends DbCreate<T>, U extends DbUpdate<T>> = {
4
4
  /** 查询条件 */
@@ -1,5 +1,5 @@
1
1
  import { Exact } from '@cloudcome/utils-core/types';
2
- import { DbCreate, DbQuery, DbSelect, DbUpdate, DbWhere } from './db.class';
2
+ import { DbCreate, DbQuery, DbSelect, DbUpdate, DbWhere } from './_db.class';
3
3
  import { DbProxy } from './proxy';
4
4
  export type DbUpsertOptions<T, S extends DbSelect<T>, C extends DbCreate<T>, U extends DbUpdate<T>> = {
5
5
  /** 查询条件 */
@@ -46,4 +46,4 @@ export type DbUpsertOutput = {
46
46
  /** 是否为更新操作 */
47
47
  updated: boolean;
48
48
  };
49
- export declare function dbUpsert<T, S extends DbSelect<T>, C extends DbCreate<T>, U extends DbUpdate<T>>(dbProxy: DbProxy<T>, options: DbUpsertOptions<T, S, C, U>): Promise<DbUpsertOutput>;
49
+ export declare function dbUpsert<D1, S1 extends DbSelect<D1>, C extends DbCreate<D1>, U extends DbUpdate<D1>>(dbProxy: DbProxy<D1>, options: DbUpsertOptions<D1, S1, C, U>): Promise<DbUpsertOutput>;