forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cradle.d.ts
122 lines (115 loc) · 4.53 KB
/
cradle.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Type definitions for cradle
// Project: https://github.com/flatiron/cradle
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "cradle" {
interface Options {
host?: string;
hostname?: string;
cache?: boolean;
raw?: boolean;
forceSave?: boolean;
auth?: string | {
username: string;
password: string;
}
ca?: string;
secure?: boolean;
retries?: number;
retryTimeout?: number;
maxSockets?: number;
}
interface Callback {
(error: any, response: any): void;
}
interface ErrorCallback {
(error: any): void;
}
export class Connection {
constructor(uri?: string, port?: number, options?: Options);
database(name: string): Database;
databases(Callback: Callback): void;
config(callback: Callback): void;
info(callback: Callback): void;
stats(callback: Callback): void;
activeTasks(callback: Callback): void;
uuids(callback: Callback): void;
uuids(count: number, callback: Callback): void;
replicate(options: {
source: string | {
url: string;
};
target: string | {
url: string;
};
cancel?: boolean;
continuous?: boolean;
create_target?: boolean;
doc_ids?: string[];
filter?: string;
proxy?: string;
query_params?: any;
}, callback: Callback): void;
}
export interface ChangesOptions {
since: number;
}
export class Database {
name: string;
get(id: string, callback: (error: any, document: any) => void): void;
get<T>(id: string, callback: (error: any, document: T) => void): void;
get(id: string, rev: string, callback: (error: any, document: any) => void): void;
get<T>(id: string, rev: string, callback: (error: any, document: T) => void): void;
get(ids: string[], callback: Callback): void;
save(document: any, callback: Callback): void;
save(id: string, document: any, callback: Callback): void;
save(id: string, revision: string, document: any,
callback: Callback): void;
save<T>(document: T, callback: Callback): void;
save<T>(id: string, document: T, callback: Callback): void;
save<T>(id: string, revision: string, document: T,
callback: Callback): void;
save(documents: any[], callback: Callback): void;
merge(id: string, document: any, callback: Callback): void;
merge<T>(id: string, document: T, callback: Callback): void;
remove(id: string, revision: string, callback: Callback): void;
update(name: string, id: string, queryObject: any, documentBody: any,
callback: Callback): void;
view(name: string, callback: Callback): void;
view(name: string, options: {
group?: boolean;
reduce?: boolean;
key?: string;
startkey?: any;
endkey?: any;
include_docs?: boolean;
limit?: number;
descending?: boolean;
}, callback: Callback): void;
temporaryView(view: any, callback: Callback): void;
create(callback: ErrorCallback): void;
exists(callback: (error: any, exists: boolean) => void): void;
destroy(callback: ErrorCallback): void;
changes(options: ChangesOptions): any;
changes(callback: (error: any, list: any[]) => void): void;
changes(options: ChangesOptions, callback: (error: any,
list: any[]) => void): void;
saveAttachment(idAndRevData: {
id: string;
rev: string;
}, attachmentData: any, callback: Callback): void;
getAttachment(id: string, attachmentName: string,
callback: Callback): void;
removeAttachment(id: string, attachmentName: string,
callback: Callback): void;
info(callback: Callback): void;
all(callback: Callback): void;
all(options: any, callback: Callback): void;
compact(callback: Callback): void;
compact(design: string, callback: Callback): void;
viewCleanup(callback: Callback): void;
replicate(target: string, callback: Callback): void;
replicate(target: string, options: any, callback: Callback): void;
}
export function setup(options: Options): void;
}