1 | import { Query } from './index';
|
2 | import { RunQueryOptions, RunQueryResponse } from './query';
|
3 | import { RequestCallback } from './request';
|
4 | declare const AGGREGATE_QUERY: unique symbol;
|
5 | /**
|
6 | * An AggregateQuery is a class that can be used to obtain results from an
|
7 | * aggregate query request.
|
8 | *
|
9 | * @see {@link https://cloud.google.com/datastore/docs/aggregation-queries| Aggregation queries Reference}
|
10 | *
|
11 | * @class
|
12 | */
|
13 | declare class AggregateQuery {
|
14 | type: symbol;
|
15 | aggregations: Array<AggregateField>;
|
16 | query: Query | undefined;
|
17 | /**
|
18 | * Build an AggregateQuery object.
|
19 | *
|
20 | * @param {Query} query
|
21 | */
|
22 | constructor(query: Query);
|
23 | /**
|
24 | * Add a `count` aggregate query to the list of aggregations.
|
25 | *
|
26 | * @param {string} alias
|
27 | * {AggregateQuery}
|
28 | */
|
29 | count(alias?: string): AggregateQuery;
|
30 | /**
|
31 | * Add a `sum` aggregate query to the list of aggregations.
|
32 | *
|
33 | * @param {string} property
|
34 | * @param {string} alias
|
35 | * @returns {AggregateQuery}
|
36 | */
|
37 | sum(property: string, alias?: string): AggregateQuery;
|
38 | /**
|
39 | * Add a `average` aggregate query to the list of aggregations.
|
40 | *
|
41 | * @param {string} property
|
42 | * @param {string} alias
|
43 | * @returns {AggregateQuery}
|
44 | */
|
45 | average(property: string, alias?: string): AggregateQuery;
|
46 | /**
|
47 | * Add a custom aggregation to the list of aggregations.
|
48 | *
|
49 | * @param {AggregateField} aggregation
|
50 | * @returns {AggregateQuery}
|
51 | */
|
52 | addAggregation(aggregation: AggregateField): AggregateQuery;
|
53 | /**
|
54 | * Add a list of custom aggregations to the list of aggregations.
|
55 | *
|
56 | * @param {AggregateField[]} aggregation
|
57 | * @returns {AggregateQuery}
|
58 | */
|
59 | addAggregations(aggregations: AggregateField[]): AggregateQuery;
|
60 | /**
|
61 | * Run the aggregation query and return the results.
|
62 | *
|
63 | * @param {RunQueryOptions | RequestCallback} [optionsOrCallback]
|
64 | * @param {function} cb The callback function.
|
65 | * @returns {void | Promise<RunQueryResponse>}
|
66 | */
|
67 | run(optionsOrCallback?: RunQueryOptions | RequestCallback, cb?: RequestCallback): void | Promise<RunQueryResponse>;
|
68 | /**
|
69 | * Get the proto for the list of aggregations.
|
70 | *
|
71 | */
|
72 | toProto(): any;
|
73 | }
|
74 | /**
|
75 | * An AggregateField is a class that contains data that defines an aggregation.
|
76 | *
|
77 | */
|
78 | declare abstract class AggregateField {
|
79 | alias_?: string;
|
80 | /**
|
81 | * Gets a copy of the Count aggregate field.
|
82 | *
|
83 | * @returns {Count}
|
84 | */
|
85 | static count(): Count;
|
86 | /**
|
87 | * Gets a copy of the Sum aggregate field.
|
88 | *
|
89 | * @returns {Sum}
|
90 | */
|
91 | static sum(property: string): Sum;
|
92 | /**
|
93 | * Gets a copy of the Average aggregate field.
|
94 | *
|
95 | * @returns {Average}
|
96 | */
|
97 | static average(property: string): Average;
|
98 | /**
|
99 | * Sets the alias on the aggregate field that should be used.
|
100 | *
|
101 | * @param {string} alias The label used in the results to describe this
|
102 | * aggregate field when a query is run.
|
103 | * @returns {AggregateField}
|
104 | */
|
105 | alias(alias?: string): AggregateField;
|
106 | /**
|
107 | * Gets the proto for the aggregate field.
|
108 | *
|
109 | */
|
110 | abstract toProto(): any;
|
111 | }
|
112 | /**
|
113 | * A Count is a class that contains data that defines a Count aggregation.
|
114 | *
|
115 | */
|
116 | declare class Count extends AggregateField {
|
117 | /**
|
118 | * Gets the proto for the count aggregate field.
|
119 | *
|
120 | */
|
121 | toProto(): any;
|
122 | }
|
123 | /**
|
124 | * A PropertyAggregateField is a class that contains data that defines any
|
125 | * aggregation that is performed on a property.
|
126 | *
|
127 | */
|
128 | declare abstract class PropertyAggregateField extends AggregateField {
|
129 | property_: string;
|
130 | abstract operator: string;
|
131 | /**
|
132 | * Build a PropertyAggregateField object.
|
133 | *
|
134 | * @param {string} property
|
135 | */
|
136 | constructor(property_: string);
|
137 | /**
|
138 | * Gets the proto for the property aggregate field.
|
139 | *
|
140 | */
|
141 | toProto(): any;
|
142 | }
|
143 | /**
|
144 | * A Sum is a class that contains data that defines a Sum aggregation.
|
145 | *
|
146 | */
|
147 | declare class Sum extends PropertyAggregateField {
|
148 | operator: string;
|
149 | }
|
150 | /**
|
151 | * An Average is a class that contains data that defines an Average aggregation.
|
152 | *
|
153 | */
|
154 | declare class Average extends PropertyAggregateField {
|
155 | operator: string;
|
156 | }
|
157 | export { AggregateField, AggregateQuery, AGGREGATE_QUERY };
|