craydent
Version:
node library based on craydent-1.9.3
137 lines (134 loc) • 3.93 kB
TypeScript
export interface IndexedArray<T> extends Array<T> {
[index: number]: T;
__indexed_buckets?: IndexedBuckets<T>;
}
export interface IndexedBuckets<T> {
[indexedProp: string]: IndexedBucket<T>;
}
export interface IndexedBucket<T> {
__bucket_keys: any;
[value: string]: T[];
}
export interface Documents<T> extends Array<T> {
[index: number]: T;
sample?: any[];
}
export interface UnwindOptions {
path?: String;
includeArrayIndex?: String;
preserveNullAndEmptyArrays?: boolean;
}
export interface Meta {
index: Number;
length: Number;
sample: any[];
stop?: boolean;
}
export type JSPrimatives = RegExp | String | Number | boolean | null;
export type MongoDBExpression<T> = {
// [field in keyof T as `$${string & field}`]: 1;
// $$NOW
}
export interface MongoDBQuery {
[field: string]: JSPrimatives | {
$exists: boolean
$in: Array<String>;
$nin: Array<String>;
$ne: JSPrimatives;
$eq: JSPrimatives;
$equal: JSPrimatives;
$lt: JSPrimatives;
$lte: JSPrimatives;
$gt: JSPrimatives;
$gte: JSPrimatives;
$or: [MongoDBQuery];
$and: [MongoDBQuery];
$all: [JSPrimatives];
$size: Number;
$elemMatch: MongoDBQuery
}
}
export interface MongoDBAccumulator {
}
export interface Stage<T, R = { [key: string]: any }> {
$project?: Omit<{ [field in keyof T]: 1 | true | 0 | false | MongoDBExpression<T> }, "_id"> | { _id: 0 | false };
$match?: MongoDBQuery;
$redact?: MongoDBExpression<T>;
$limit?: Number;
$skip?: Number;
$unwind?: {
path: String;
includeArrayIndex?: String;
preserveNullAndEmptyArrays?: boolean;
};
$group?: Omit<{ [field in keyof T]: MongoDBAccumulator }, "_id"> | { _id: MongoDBExpression<T> };
$sort?: { [field in keyof T]: 1 | -1 | { $meta: "textScore" | "indexKey" } };
$out?: String | any[];
$sample?: { size: Number };
$lookup?: {
from: R;
localField: keyof T;
foreignField: keyof R;
as: String;
};
}
export type StageKeys<T> = keyof Stage<T>;
export interface MongoPipelines {
$project?: any;
$match?: any;
$redact?: any;
$limit?: any;
$skip?: any;
$unwind?: any;
$group?: any;
$sample?: any;
$sort?: any;
$lookup?: any;
$out?: any;
}
export declare type MongoReducer<T> = (key?: String, values?: Array<T>) => T;
export declare type MongoMapReduceOptions<T> = {
sort?: String | any;
query?: WhereCondition;
limit?: Number;
finalize?: MongoFinalize<T>;
out?: String | Array<any>;
};
export declare type MongoFinalize<T> = (key: string, value: T) => T;
export declare type MongoGroupFinalize<T> = (value: T) => T | void;
export declare type MongoSet = any;
export interface ExtendedArray extends Array<any> {
[index: number]: any;
items?: Number;
}
export interface SearchRangeOptions {
condition: any;
findIndex?: boolean;
}
export interface CreateFuncOptions {
ifblock?: String | boolean;
projection?: any;
_refs?: any;
arr: any[];
limit: Number;
condition: any;
}
export declare type TreeParentFinder<T> = (value?: T) => boolean;
export declare type TreeChildFinder<T> = (value?: T) => boolean;
export declare type TreeOptions = { childProperty?: String; };
export declare type WhereCondition = any;
export declare type DeleteOptions = { justOne: boolean; };
export declare type GroupOptions<T> = {
key?: any;
field?: any;
condition?: String | any;
cond?: String | any;
reduce?: (current: any, accumulator: any) => void;
initial?: any;
keyf?: Array<String> | ((doc: any) => Array<String>);
finalize?: MongoGroupFinalize<T>;
};
export declare type ArrayIterator<T> = (obj: T, index?: Number | T, objs?: Array<T>) => any;
export interface Fields {
[key: string]: boolean | 0 | 1;
}