@google-cloud/datastore
Version:
Cloud Datastore Client Library for Node.js
93 lines (92 loc) • 2.96 kB
TypeScript
import { Operator, Filter as IFilter } from './query';
import { entity } from './entity';
import Key = entity.Key;
declare enum CompositeOperator {
AND = "AND",
OR = "OR"
}
/**
* And filters are composed of many other filters and when they are applied
* then query results are only returned when they pass through all these other
* filters.
*
* @param {EntityFilter[]} filters The list of filters that make up the AND filter.
* @returns {CompositeFilter} A composite AND filter.
*
*/
export declare function and(filters: EntityFilter[]): CompositeFilter;
/**
* Or filters are composed of many other filters and when they are applied
* then query results are returned when they pass through any of these other
* filters.
*
* @param {EntityFilter[]} filters The list of filters that make up the OR filter.
* @returns {CompositeFilter} A composite OR filter.
*
*/
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 The property name that the filter will be applied to.
* @param {Operator} operator The comparison operator that the filter applies.
* @param {any} val The value that the filter compares the property to.
*/
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 The filters that make up the composite filter.
*/
constructor(filters: EntityFilter[], op: CompositeOperator);
/**
* Gets the proto for the filter.
*
*/
toProto(): any;
}
export declare function isFilter(filter: any): filter is EntityFilter;
export {};