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