mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
added aggregate and distinct to Parse
This commit is contained in:
Vendored
+14
-1
@@ -607,6 +607,7 @@ declare namespace Parse {
|
||||
|
||||
static or<U extends Object>(...var_args: Query<U>[]): Query<U>;
|
||||
|
||||
aggregate(pipeline: Query.AggregationOptions|Query.AggregationOptions[]): Query<T>;
|
||||
addAscending(key: string): Query<T>;
|
||||
addAscending(key: string[]): Query<T>;
|
||||
addDescending(key: string): Query<T>;
|
||||
@@ -623,6 +624,7 @@ declare namespace Parse {
|
||||
doesNotExist(key: string): Query<T>;
|
||||
doesNotMatchKeyInQuery<U extends Object>(key: string, queryKey: string, query: Query<U>): Query<T>;
|
||||
doesNotMatchQuery<U extends Object>(key: string, query: Query<U>): Query<T>;
|
||||
distinct(key: string): Query<T>;
|
||||
each(callback: Function, options?: Query.EachOptions): Promise<void>;
|
||||
endsWith(key: string, suffix: string): Query<T>;
|
||||
equalTo(key: string, value: any): Query<T>;
|
||||
@@ -659,6 +661,17 @@ declare namespace Parse {
|
||||
interface FindOptions extends SuccessFailureOptions, ScopeOptions { }
|
||||
interface FirstOptions extends SuccessFailureOptions, ScopeOptions { }
|
||||
interface GetOptions extends SuccessFailureOptions, ScopeOptions { }
|
||||
|
||||
// According to http://docs.parseplatform.org/rest/guide/#aggregate-queries
|
||||
interface AggregationOptions {
|
||||
group?: { objectId?: string, [key:string]: any };
|
||||
match?: {[key: string]: any};
|
||||
project?: {[key: string]: any};
|
||||
limit?: number;
|
||||
skip?: number;
|
||||
// Sort documentation https://docs.mongodb.com/v3.2/reference/operator/aggregation/sort/#pipe._S_sort
|
||||
sort?: {[key: string]: 1|-1};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1151,4 +1164,4 @@ declare module "parse/node" {
|
||||
declare module "parse" {
|
||||
import * as parse from "parse/node";
|
||||
export = parse
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,16 @@ function test_query() {
|
||||
query.include("score");
|
||||
query.include(["score.team"]);
|
||||
|
||||
// Find objects that match the aggregation pipeline
|
||||
query.aggregate({
|
||||
group:{
|
||||
objectId: '$name'
|
||||
}
|
||||
});
|
||||
|
||||
// Find objects with distinct key
|
||||
query.distinct('name');
|
||||
|
||||
const testQuery = Parse.Query.or(query, query);
|
||||
}
|
||||
|
||||
@@ -396,7 +406,7 @@ function test_cloud_functions() {
|
||||
|
||||
Parse.Cloud.beforeSave('MyCustomClass', (request: Parse.Cloud.BeforeSaveRequest,
|
||||
response: Parse.Cloud.BeforeSaveResponse) => {
|
||||
|
||||
|
||||
if (request.object.isNew()) {
|
||||
if (!request.object.has('immutable')) return response.error('Field immutable is required')
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user