@google-cloud/datastore
Version:
Cloud Datastore Client Library for Node.js
75 lines (74 loc) • 2.13 kB
TypeScript
import { Operator, Filter as IFilter } from './query';
import { entity } from './entity';
import Key = entity.Key;
declare enum CompositeOperator {
AND = "AND",
OR = "OR"
}
export declare function and(filters: EntityFilter[]): CompositeFilter;
export declare function or(filters: EntityFilter[]): CompositeFilter;
/**
* A Filter is a class that contains data for a filter that can be translated
* into a proto when needed.
*
* @see {@link https://cloud.google.com/datastore/docs/concepts/queries#filters| Filters Reference}
*
*/
export declare abstract class EntityFilter {
/**
* Gets the proto for the filter.
*
*/
abstract toProto(): any;
}
export type AllowedFilterValueType<T> = T extends '__key__' ? Key | Key[] : unknown;
/**
* A PropertyFilter is a filter that gets applied to a query directly.
*
* @see {@link https://cloud.google.com/datastore/docs/concepts/queries#property_filters| Property filters Reference}
*
* @class
*/
export declare class PropertyFilter<T extends string> extends EntityFilter implements IFilter {
name: T;
op: Operator;
val: AllowedFilterValueType<T>;
/**
* Build a Property Filter object.
*
* @param {string} Property
* @param {Operator} operator
* @param {any} val
*/
constructor(name: T, op: Operator, val: AllowedFilterValueType<T>);
/**
* Gets the proto for the filter.
*
*/
toProto(): any;
}
/**
* A CompositeFilter is a filter that combines other filters and applies that
* combination to a query.
*
* @see {@link https://cloud.google.com/datastore/docs/concepts/queries#composite_filters| Composite filters Reference}
*
* @class
*/
declare class CompositeFilter extends EntityFilter {
filters: EntityFilter[];
op: string;
/**
* Build a Composite Filter object.
*
* @param {EntityFilter[]} filters
*/
constructor(filters: EntityFilter[], op: CompositeOperator);
/**
* Gets the proto for the filter.
*
*/
toProto(): any;
}
export declare function isFilter(filter: any): filter is EntityFilter;
export {};