Skip to content

Commit 863ab95

Browse files
authored
Merge pull request #341 from agentdong/fix-aggregateType
fix: 类型补全Aggregate
2 parents f971662 + 12a8004 commit 863ab95

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

types/wx/lib.wx.cloud.d.ts

+72
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,77 @@ declare namespace DB {
339339
collection(collectionName: string): CollectionReference
340340
}
341341

342+
interface Aggregate {
343+
/**
344+
* @description 聚合阶段。添加新字段到输出的记录。经过 addFields 聚合阶段,输出的所有记录中除了输入时带有的字段外,还将带有 addFields 指定的字段。
345+
*/
346+
addFields(object: any): Aggregate
347+
/**
348+
* @description 聚合阶段。将输入记录根据给定的条件和边界划分成不同的组,每组即一个 bucket。
349+
*/
350+
bucket(object: any): Aggregate
351+
/**
352+
* @description 聚合阶段。将输入记录根据给定的条件划分成不同的组,每组即一个 bucket。与 bucket 的其中一个不同之处在于无需指定 boundaries,bucketAuto 会自动尝试将记录尽可能平均地分散到每组中。
353+
*/
354+
bucketAuto(object: any): Aggregate
355+
/**
356+
* @description 聚合阶段。计算上一聚合阶段输入到本阶段的记录数,输出一个记录,其中指定字段的值为记录数。
357+
*/
358+
count(fieldName: string): Aggregate
359+
/**
360+
* @description 标志聚合操作定义完成,发起实际聚合操作。
361+
*/
362+
end(): Promise<any>
363+
/**
364+
* @description 聚合阶段。将记录按照离给定点从近到远输出。
365+
*/
366+
geoNear(object: any): Aggregate
367+
/**
368+
* @description 聚合阶段。将输入记录按给定表达式分组,输出时每个记录代表一个分组,每个记录的 _id 是区分不同组的 key。输出记录中也可以包括累计值,将输出字段设为累计值即会从该分组中计算累计值。
369+
*/
370+
group(object: any): Aggregate
371+
/**
372+
* @description 聚合阶段。限制输出到下一阶段的记录数。
373+
*/
374+
limit(value: number): Aggregate
375+
/**
376+
* @description 聚合阶段。聚合阶段。联表查询。与同个数据库下的一个指定的集合做 left outer join(左外连接)。对该阶段的每一个输入记录,lookup 会在该记录中增加一个数组字段,该数组是被联表中满足匹配条件的记录列表。lookup 会将连接后的结果输出给下个阶段。
377+
*/
378+
lookup(object: any): Aggregate
379+
/**
380+
* @description 聚合阶段。根据条件过滤文档,并且把符合条件的文档传递给下一个流水线阶段。
381+
*/
382+
match(object: any): Aggregate
383+
/**
384+
* @description 聚合阶段。把指定的字段传递给下一个流水线,指定的字段可以是某个已经存在的字段,也可以是计算出来的新字段。
385+
*/
386+
project(object: any): Aggregate
387+
/**
388+
* @description 聚合阶段。指定一个已有字段作为输出的根节点,也可以指定一个计算出的新字段作为根节点。
389+
*/
390+
replaceRoot(object: any): Aggregate
391+
/**
392+
* @description 聚合阶段。随机从文档中选取指定数量的记录。
393+
*/
394+
sample(size: number): Aggregate
395+
/**
396+
* @description 聚合阶段。指定一个正整数,跳过对应数量的文档,输出剩下的文档。
397+
*/
398+
skip(value: number): Aggregate
399+
/**
400+
* @description 聚合阶段。根据指定的字段,对输入的文档进行排序。
401+
*/
402+
sort(object: any): Aggregate
403+
/**
404+
* @description 聚合阶段。根据传入的表达式,将传入的集合进行分组(group)。然后计算不同组的数量,并且将这些组按照它们的数量进行排序,返回排序后的结果。
405+
*/
406+
sortByCount(object: any): Aggregate
407+
/**
408+
* @description 聚合阶段。使用指定的数组字段中的每个元素,对文档进行拆分。拆分后,文档会从一个变为一个或多个,分别对应数组的每个元素。
409+
*/
410+
unwind(value: string | object): Aggregate
411+
}
412+
342413
class CollectionReference extends Query {
343414
readonly collectionName: string
344415

@@ -348,6 +419,7 @@ declare namespace DB {
348419

349420
add(options: OQ<IAddDocumentOptions>): void
350421
add(options: RQ<IAddDocumentOptions>): Promise<IAddResult>
422+
aggregate(): Aggregate
351423
}
352424

353425
class DocumentReference {

0 commit comments

Comments
 (0)