UNPKG

7.8 kBTypeScriptView Raw
1import { CppTopologyCollectionsManifestCollection, CppTopologyCollectionsManifestScope } from './binding';
2import { Bucket } from './bucket';
3import { NodeCallback } from './utilities';
4/**
5 * Provides options for configuring a collection.
6 *
7 * @category Management
8 */
9export interface ICollectionSpec {
10 /**
11 * The name of the collection.
12 */
13 name: string;
14 /**
15 * The name of the scope containing this collection.
16 */
17 scopeName: string;
18 /**
19 * The maximum expiry for documents in this collection.
20 *
21 * @see {@link IBucketSettings.maxExpiry}
22 */
23 maxExpiry?: number;
24 /**
25 * The history retention override setting in this collection.
26 * Only supported on Magma Buckets.
27 *
28 * @see {@link StorageBackend.Magma}.
29 */
30 history?: boolean;
31}
32/**
33 * Contains information about a collection.
34 *
35 * @category Management
36 */
37export declare class CollectionSpec {
38 /**
39 * The name of the collection.
40 */
41 name: string;
42 /**
43 * The name of the scope this collection exists in.
44 */
45 scopeName: string;
46 /**
47 * The maximum expiry for documents in this collection.
48 *
49 * @see {@link IBucketSettings.maxExpiry}
50 */
51 maxExpiry: number;
52 /**
53 * The history retention override setting in this collection.
54 * Only supported on Magma Buckets.
55 *
56 * @see {@link StorageBackend.Magma}.
57 */
58 history?: boolean;
59 /**
60 * @internal
61 */
62 constructor(data: CollectionSpec);
63 /**
64 * @internal
65 */
66 static _fromCppData(scopeName: string, data: CppTopologyCollectionsManifestCollection): CollectionSpec;
67}
68/**
69 * Contains information about a scope.
70 *
71 * @category Management
72 */
73export declare class ScopeSpec {
74 /**
75 * The name of the scope.
76 */
77 name: string;
78 /**
79 * The collections which exist in this scope.
80 */
81 collections: CollectionSpec[];
82 /**
83 * @internal
84 */
85 constructor(data: ScopeSpec);
86 /**
87 * @internal
88 */
89 static _fromCppData(data: CppTopologyCollectionsManifestScope): ScopeSpec;
90}
91/**
92 * The settings to use when creating the collection.
93 *
94 * @category Management
95 */
96export interface CreateCollectionSettings {
97 /**
98 * The maximum expiry for documents in this collection.
99 *
100 * @see {@link IBucketSettings.maxExpiry}
101 */
102 maxExpiry?: number;
103 /**
104 * The history retention override setting in this collection.
105 * Only supported on Magma Buckets.
106 *
107 * @see {@link StorageBackend.Magma}.
108 */
109 history?: boolean;
110}
111/**
112 * The settings which should be updated on the collection.
113 *
114 * @category Management
115 */
116export interface UpdateCollectionSettings {
117 /**
118 * The maximum expiry for documents in this collection.
119 *
120 * @see {@link IBucketSettings.maxExpiry}
121 */
122 maxExpiry?: number;
123 /**
124 * The history retention override setting in this collection.
125 * Only supported on Magma Buckets.
126 *
127 * @see {@link StorageBackend.Magma}.
128 */
129 history?: boolean;
130}
131/**
132 * @category Management
133 */
134export interface CreateCollectionOptions {
135 /**
136 * The timeout for this operation, represented in milliseconds.
137 */
138 timeout?: number;
139}
140/**
141 * @category Management
142 */
143export interface GetAllScopesOptions {
144 /**
145 * The timeout for this operation, represented in milliseconds.
146 */
147 timeout?: number;
148}
149/**
150 * @category Management
151 */
152export interface DropCollectionOptions {
153 /**
154 * The timeout for this operation, represented in milliseconds.
155 */
156 timeout?: number;
157}
158/**
159 * @category Management
160 */
161export interface CreateScopeOptions {
162 /**
163 * The timeout for this operation, represented in milliseconds.
164 */
165 timeout?: number;
166}
167/**
168 * @category Management
169 */
170export interface DropScopeOptions {
171 /**
172 * The timeout for this operation, represented in milliseconds.
173 */
174 timeout?: number;
175}
176/**
177 * @category Management
178 */
179export interface UpdateCollectionOptions {
180 /**
181 * The timeout for this operation, represented in milliseconds.
182 */
183 timeout?: number;
184}
185/**
186 * CollectionManager allows the management of collections within a Bucket.
187 *
188 * @category Management
189 */
190export declare class CollectionManager {
191 private _bucket;
192 /**
193 * @internal
194 */
195 constructor(bucket: Bucket);
196 private get _cluster();
197 /**
198 * Returns all configured scopes along with their collections.
199 *
200 * @param options Optional parameters for this operation.
201 * @param callback A node-style callback to be invoked after execution.
202 */
203 getAllScopes(options?: GetAllScopesOptions, callback?: NodeCallback<ScopeSpec[]>): Promise<ScopeSpec[]>;
204 /**
205 * Creates a collection in a scope.
206 *
207 * @param collectionSpec Specifies the settings for the new collection.
208 * @param options Optional parameters for this operation.
209 * @param callback A node-style callback to be invoked after execution.
210 * @deprecated Use the other overload instead.
211 */
212 createCollection(collectionSpec: ICollectionSpec, options?: CreateCollectionOptions, callback?: NodeCallback<void>): Promise<void>;
213 /**
214 * Creates a collection in a scope.
215 */
216 createCollection(collectionName: string, scopeName: string, options?: CreateCollectionOptions, callback?: NodeCallback<void>): Promise<void>;
217 /**
218 * Creates a collection in a scope.
219 *
220 * @param collectionName The name of the collection.
221 * @param scopeName The name of the scope containing this collection.
222 * @param settings The settings to use on creating the collection.
223 * @param options Optional parameters for this operation.
224 * @param callback A node-style callback to be invoked after execution.
225 */
226 createCollection(collectionName: string, scopeName: string, settings?: CreateCollectionSettings, options?: CreateCollectionOptions, callback?: NodeCallback<void>): Promise<void>;
227 /**
228 * Drops a collection from a scope.
229 *
230 * @param collectionName The name of the collection to drop.
231 * @param scopeName The name of the scope containing the collection to drop.
232 * @param options Optional parameters for this operation.
233 * @param callback A node-style callback to be invoked after execution.
234 */
235 dropCollection(collectionName: string, scopeName: string, options?: DropCollectionOptions, callback?: NodeCallback<void>): Promise<void>;
236 /**
237 * Updates a collection in a scope.
238 *
239 * @param collectionName The name of the collection to update.
240 * @param scopeName The name of the scope containing the collection.
241 * @param settings The settings to update on the collection.
242 * @param options Optional parameters for this operation.
243 * @param callback A node-style callback to be invoked after execution.
244 */
245 updateCollection(collectionName: string, scopeName: string, settings: UpdateCollectionSettings, options?: UpdateCollectionOptions, callback?: NodeCallback<void>): Promise<void>;
246 /**
247 * Creates a new scope.
248 *
249 * @param scopeName The name of the new scope to create.
250 * @param options Optional parameters for this operation.
251 * @param callback A node-style callback to be invoked after execution.
252 */
253 createScope(scopeName: string, options?: CreateScopeOptions, callback?: NodeCallback<void>): Promise<void>;
254 /**
255 * Drops a scope.
256 *
257 * @param scopeName The name of the scope to drop.
258 * @param options Optional parameters for this operation.
259 * @param callback A node-style callback to be invoked after execution.
260 */
261 dropScope(scopeName: string, options?: DropScopeOptions, callback?: NodeCallback<void>): Promise<void>;
262}