UNPKG

2.86 kBTypeScriptView Raw
1// http://jsforce.github.io/jsforce/doc/Query.html
2import { Readable } from 'stream';
3import { RecordResult } from './record-result';
4
5export interface ExecuteOptions {
6 autoFetch?: boolean | undefined;
7 maxFetch?: number | undefined;
8 headers?: object | undefined;
9 scanAll?: boolean | undefined;
10}
11
12export interface QueryResult<T> {
13 done: boolean;
14 nextRecordsUrl?: string | undefined;
15 totalSize: number;
16 records: T[];
17}
18
19export class Query<T> extends Readable implements Promise<T> {
20 end(): Query<T>;
21
22 filter(filter: Object): Query<T>;
23
24 include(include: string): Query<T>;
25
26 hint(hint: Object): Query<T>;
27
28 limit(value: number): Query<T>;
29
30 maxFetch(value: number): Query<T>;
31
32 offset(value: number): Query<T>;
33
34 skip(value: number): Query<T>;
35
36 sort(keyOrList: string | Object[] | Object, direction?: 'ASC' | 'DESC' | number): Query<T>;
37
38 run(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
39
40 execute(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
41
42 exec(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
43
44 del(type?: string, callback?: (err: Error, ret: RecordResult) => void): any;
45 del(callback?: (err: Error, ret: RecordResult) => void): any;
46
47 delete(type?: string, callback?: (err: Error, ret: RecordResult) => void): any;
48 delete(callback?: (err: Error, ret: RecordResult) => void): any;
49
50 destroy(type?: string, callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult[]>;
51 destroy(callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult[]>;
52 destroy(error?: Error): this;
53
54 explain(callback?: (err: Error, info: ExplainInfo) => void): Promise<ExplainInfo>;
55
56 map(callback: (currentValue: Object) => void): Promise<any>;
57
58 scanAll(value: boolean): Query<T>;
59
60 select(fields: Object | string[] | string): Query<T>;
61
62 thenCall(callback?: (err: Error, records: T) => void): Query<T>;
63
64 toSOQL(callback: (err: Error, soql: string) => void): Promise<string>;
65
66 update(
67 mapping: any,
68 type: string,
69 callback?: (err: Error, records: RecordResult[]) => void,
70 ): Promise<RecordResult[]>;
71 update(mapping: any, callback?: (err: Error, records: RecordResult[]) => void): Promise<RecordResult[]>;
72
73 where(conditions: Object | string): Query<T>;
74
75 finally(): Promise<T>;
76
77 [Symbol.toStringTag]: 'Promise';
78
79 catch<TResult>(onrejected?: ((reason: any) => (PromiseLike<TResult> | TResult))): Promise<T | TResult>;
80
81 then<TResult1, TResult2>(onfulfilled?: ((value: T) => (PromiseLike<TResult1> | TResult1)),
82 onrejected?: ((reason: any) => (PromiseLike<TResult2> | TResult2))): Promise<TResult1 | TResult2>;
83}
84
85export class ExplainInfo {}
86
\No newline at end of file