UNPKG

8.21 kBTypeScriptView Raw
1import { Collection } from './collection';
2import { NodeCallback } from './utilities';
3/**
4 * CouchbaseList provides a simplified interface for storing lists
5 * within a Couchbase document.
6 *
7 * @see {@link Collection.list}
8 * @category Datastructures
9 */
10export declare class CouchbaseList {
11 private _coll;
12 private _key;
13 /**
14 * @internal
15 */
16 constructor(collection: Collection, key: string);
17 private _get;
18 /**
19 * Returns the entire list of items in this list.
20 *
21 * @param callback A node-style callback to be invoked after execution.
22 */
23 getAll(callback?: NodeCallback<any[]>): Promise<any[]>;
24 /**
25 * Iterates each item in the list.
26 *
27 * @param rowCallback A callback invoked for each item in the list.
28 * @param callback A node-style callback to be invoked after execution.
29 */
30 forEach(rowCallback: (value: any, index: number, array: CouchbaseList) => void, callback?: NodeCallback<void>): Promise<void>;
31 /**
32 * Provides the ability to async-for loop this object.
33 */
34 [Symbol.asyncIterator](): AsyncIterator<any>;
35 /**
36 * Retrieves the item at a specific index in the list.
37 *
38 * @param index The index to retrieve.
39 * @param callback A node-style callback to be invoked after execution.
40 */
41 getAt(index: number, callback?: NodeCallback<any>): Promise<any>;
42 /**
43 * Removes an item at a specific index from the list.
44 *
45 * @param index The index to remove.
46 * @param callback A node-style callback to be invoked after execution.
47 */
48 removeAt(index: number, callback?: NodeCallback<void>): Promise<void>;
49 /**
50 * Returns the index of a specific value from the list.
51 *
52 * @param value The value to search for.
53 * @param callback A node-style callback to be invoked after execution.
54 */
55 indexOf(value: any, callback?: NodeCallback<number>): Promise<number>;
56 /**
57 * Returns the number of items in the list.
58 *
59 * @param callback A node-style callback to be invoked after execution.
60 */
61 size(callback?: NodeCallback<number>): Promise<number>;
62 /**
63 * Adds a new item to the end of the list.
64 *
65 * @param value The value to add.
66 * @param callback A node-style callback to be invoked after execution.
67 */
68 push(value: any, callback?: NodeCallback<void>): Promise<void>;
69 /**
70 * Adds a new item to the beginning of the list.
71 *
72 * @param value The value to add.
73 * @param callback A node-style callback to be invoked after execution.
74 */
75 unshift(value: any, callback?: NodeCallback<void>): Promise<void>;
76}
77/**
78 * CouchbaseMap provides a simplified interface for storing a map
79 * within a Couchbase document.
80 *
81 * @see {@link Collection.map}
82 * @category Datastructures
83 */
84export declare class CouchbaseMap {
85 private _coll;
86 private _key;
87 /**
88 * @internal
89 */
90 constructor(collection: Collection, key: string);
91 private _get;
92 /**
93 * Returns an object representing all items in the map.
94 *
95 * @param callback A node-style callback to be invoked after execution.
96 */
97 getAll(callback?: NodeCallback<{
98 [key: string]: any;
99 }>): Promise<{
100 [key: string]: any;
101 }>;
102 /**
103 * Iterates through every item in the map.
104 *
105 * @param rowCallback A callback invoked for each item in the list.
106 * @param callback A node-style callback to be invoked after execution.
107 */
108 forEach(rowCallback: (value: any, key: string, map: CouchbaseMap) => void, callback?: NodeCallback<void>): Promise<void>;
109 /**
110 * Provides the ability to async-for loop this object.
111 */
112 [Symbol.asyncIterator](): AsyncIterator<[any, string]>;
113 /**
114 * Sets a specific to the specified value in the map.
115 *
116 * @param item The key in the map to set.
117 * @param value The new value to set.
118 * @param callback A node-style callback to be invoked after execution.
119 */
120 set(item: string, value: any, callback?: NodeCallback<void>): Promise<void>;
121 /**
122 * Fetches a specific key from the map.
123 *
124 * @param item The key in the map to retrieve.
125 * @param callback A node-style callback to be invoked after execution.
126 */
127 get(item: string, callback?: NodeCallback<any>): Promise<any>;
128 /**
129 * Removes a specific key from the map.
130 *
131 * @param item The key in the map to remove.
132 * @param callback A node-style callback to be invoked after execution.
133 */
134 remove(item: string, callback?: NodeCallback<void>): Promise<void>;
135 /**
136 * Checks whether a specific key exists in the map.
137 *
138 * @param item The key in the map to search for.
139 * @param callback A node-style callback to be invoked after execution.
140 */
141 exists(item: string, callback?: NodeCallback<boolean>): Promise<boolean>;
142 /**
143 * Returns a list of all the keys which exist in the map.
144 *
145 * @param callback A node-style callback to be invoked after execution.
146 */
147 keys(callback?: NodeCallback<string[]>): Promise<string[]>;
148 /**
149 * Returns a list of all the values which exist in the map.
150 *
151 * @param callback A node-style callback to be invoked after execution.
152 */
153 values(callback?: NodeCallback<any[]>): Promise<any[]>;
154 /**
155 * Returns the number of items that exist in the map.
156 *
157 * @param callback A node-style callback to be invoked after execution.
158 */
159 size(callback?: NodeCallback<number>): Promise<number>;
160}
161/**
162 * CouchbaseQueue provides a simplified interface for storing a queue
163 * within a Couchbase document.
164 *
165 * @see {@link Collection.queue}
166 * @category Datastructures
167 */
168export declare class CouchbaseQueue {
169 private _coll;
170 private _key;
171 /**
172 * @internal
173 */
174 constructor(collection: Collection, key: string);
175 private _get;
176 /**
177 * Returns the number of items in the queue.
178 *
179 * @param callback A node-style callback to be invoked after execution.
180 */
181 size(callback?: NodeCallback<number>): Promise<number>;
182 /**
183 * Adds a new item to the back of the queue.
184 *
185 * @param value The value to add.
186 * @param callback A node-style callback to be invoked after execution.
187 */
188 push(value: any, callback?: NodeCallback<void>): Promise<void>;
189 /**
190 * Removes an item from the front of the queue.
191 *
192 * @param callback A node-style callback to be invoked after execution.
193 */
194 pop(callback?: NodeCallback<any>): Promise<any>;
195}
196/**
197 * CouchbaseSet provides a simplified interface for storing a set
198 * within a Couchbase document.
199 *
200 * @see {@link Collection.set}
201 * @category Datastructures
202 */
203export declare class CouchbaseSet {
204 private _coll;
205 private _key;
206 /**
207 * @internal
208 */
209 constructor(collection: Collection, key: string);
210 private _get;
211 /**
212 * Adds a new item to the set. Returning whether the item already existed
213 * in the set or not.
214 *
215 * @param item The item to add.
216 * @param callback A node-style callback to be invoked after execution.
217 */
218 add(item: any, callback?: NodeCallback<boolean>): Promise<boolean>;
219 /**
220 * Returns whether a specific value already exists in the set.
221 *
222 * @param item The value to search for.
223 * @param callback A node-style callback to be invoked after execution.
224 */
225 contains(item: any, callback?: NodeCallback<boolean>): Promise<boolean>;
226 /**
227 * Removes a specific value from the set.
228 *
229 * @param item The value to remove.
230 * @param callback A node-style callback to be invoked after execution.
231 */
232 remove(item: any, callback?: NodeCallback<void>): Promise<void>;
233 /**
234 * Returns a list of all values in the set.
235 *
236 * @param callback A node-style callback to be invoked after execution.
237 */
238 values(callback?: NodeCallback<any[]>): Promise<any[]>;
239 /**
240 * Returns the number of elements in this set.
241 *
242 * @param callback A node-style callback to be invoked after execution.
243 */
244 size(callback?: NodeCallback<number>): Promise<number>;
245}