albedo-node 0.5.91 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +47 -1
- package/dist/index.js +41 -2
- package/example/bun.lock +4 -2
- package/example/package.json +1 -1
- package/native/albedo.aarch64_linux_gnu.node +0 -0
- package/native/albedo.aarch64_linux_musl.node +0 -0
- package/native/albedo.aarch64_macos.node +0 -0
- package/native/albedo.x86_64_linux_gnu.node +0 -0
- package/native/albedo.x86_64_linux_musl.node +0 -0
- package/native/albedo.x86_64_macos.node +0 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,28 @@ interface ObjectIdConstructor {
|
|
|
12
12
|
new (buffer?: ByteBuffer): ObjectIdInstance;
|
|
13
13
|
fromString(str: string): ObjectIdInstance;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Controls when fsync is called to guarantee write durability.
|
|
17
|
+
*/
|
|
18
|
+
type WriteDurability = "all" | {
|
|
19
|
+
periodic: number;
|
|
20
|
+
} | "manual";
|
|
21
|
+
/**
|
|
22
|
+
* Controls how page reads interact with the WAL.
|
|
23
|
+
*/
|
|
24
|
+
type ReadDurability = "shared" | "process";
|
|
25
|
+
/**
|
|
26
|
+
* Options for opening a bucket.
|
|
27
|
+
*/
|
|
28
|
+
interface OpenBucketOptions {
|
|
29
|
+
buildIdIndex?: boolean;
|
|
30
|
+
mode?: string;
|
|
31
|
+
auto_vaccuum?: boolean;
|
|
32
|
+
page_cache_capacity?: number;
|
|
33
|
+
wal?: boolean;
|
|
34
|
+
write_durability?: WriteDurability;
|
|
35
|
+
read_durability?: ReadDurability;
|
|
36
|
+
}
|
|
15
37
|
export declare const albedo: any;
|
|
16
38
|
export default albedo;
|
|
17
39
|
export declare const BSON: {
|
|
@@ -68,7 +90,7 @@ export declare class Bucket {
|
|
|
68
90
|
* const bucket = Bucket.open('data.db');
|
|
69
91
|
* ```
|
|
70
92
|
*/
|
|
71
|
-
static open(path: string): Bucket;
|
|
93
|
+
static open(path: string, options?: OpenBucketOptions): Bucket;
|
|
72
94
|
/**
|
|
73
95
|
* Close the bucket and release native resources.
|
|
74
96
|
* @example
|
|
@@ -136,6 +158,30 @@ export declare class Bucket {
|
|
|
136
158
|
* ```
|
|
137
159
|
*/
|
|
138
160
|
list<T>(query?: object | Query): Generator<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Async iterator that continuously polls for documents matching the
|
|
163
|
+
* optional query. Unlike `list`, when there are no more results the
|
|
164
|
+
* iterator waits for `pollingTimeout` milliseconds and retries,
|
|
165
|
+
* making it suitable for watching a bucket for new data.
|
|
166
|
+
*
|
|
167
|
+
* The native cursor is closed automatically when the consumer breaks
|
|
168
|
+
* out of the loop or the iterator is otherwise disposed.
|
|
169
|
+
*
|
|
170
|
+
* @param query - filter or `Query` object
|
|
171
|
+
* @param options - polling configuration
|
|
172
|
+
* @param options.pollingTimeout - ms to wait before retrying when
|
|
173
|
+
* `listData` returns `null` (default `50`)
|
|
174
|
+
* @yields each document deserialized from the bucket
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* for await (const user of bucket.stream<User>(where('active', { $eq: true }))) {
|
|
178
|
+
* console.log(user);
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
stream<T>(query?: object | Query, options?: {
|
|
183
|
+
pollingTimeout?: number;
|
|
184
|
+
}): AsyncGenerator<T>;
|
|
139
185
|
/**
|
|
140
186
|
* Collect all documents matching the optional query into an array.
|
|
141
187
|
* @param query - filter or `Query` object
|
package/dist/index.js
CHANGED
|
@@ -89,8 +89,8 @@ class Bucket {
|
|
|
89
89
|
* const bucket = Bucket.open('data.db');
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
static open(path) {
|
|
93
|
-
const handle = exports.albedo.open(path);
|
|
92
|
+
static open(path, options) {
|
|
93
|
+
const handle = options ? exports.albedo.open_with_options(path, options) : exports.albedo.open(path);
|
|
94
94
|
return new Bucket(handle);
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
@@ -183,6 +183,45 @@ class Bucket {
|
|
|
183
183
|
exports.albedo.listClose(cursor);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Async iterator that continuously polls for documents matching the
|
|
188
|
+
* optional query. Unlike `list`, when there are no more results the
|
|
189
|
+
* iterator waits for `pollingTimeout` milliseconds and retries,
|
|
190
|
+
* making it suitable for watching a bucket for new data.
|
|
191
|
+
*
|
|
192
|
+
* The native cursor is closed automatically when the consumer breaks
|
|
193
|
+
* out of the loop or the iterator is otherwise disposed.
|
|
194
|
+
*
|
|
195
|
+
* @param query - filter or `Query` object
|
|
196
|
+
* @param options - polling configuration
|
|
197
|
+
* @param options.pollingTimeout - ms to wait before retrying when
|
|
198
|
+
* `listData` returns `null` (default `50`)
|
|
199
|
+
* @yields each document deserialized from the bucket
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* for await (const user of bucket.stream<User>(where('active', { $eq: true }))) {
|
|
203
|
+
* console.log(user);
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
async *stream(query, options) {
|
|
208
|
+
const pollingTimeout = options?.pollingTimeout ?? 50;
|
|
209
|
+
const cursor = exports.albedo.list(this.handle, Bucket.convertToQuery(query));
|
|
210
|
+
try {
|
|
211
|
+
while (true) {
|
|
212
|
+
const data = exports.albedo.listData(cursor);
|
|
213
|
+
if (data !== null) {
|
|
214
|
+
yield data;
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
await new Promise((r) => setTimeout(r, pollingTimeout));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
exports.albedo.listClose(cursor);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
186
225
|
/**
|
|
187
226
|
* Collect all documents matching the optional query into an array.
|
|
188
227
|
* @param query - filter or `Query` object
|
package/example/bun.lock
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"": {
|
|
6
6
|
"name": "example",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"albedo-node": "0.5.
|
|
8
|
+
"albedo-node": "0.5.91",
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/bun": "latest",
|
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
"@types/node": ["@types/node@24.10.13", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg=="],
|
|
22
22
|
|
|
23
|
-
"albedo-node": ["albedo-node@0.5.
|
|
23
|
+
"albedo-node": ["albedo-node@0.5.91", "", { "dependencies": { "detect-libc": "^2.1.2" } }, "sha512-jjb4t9jKi3COnLnoc94ABnoHB24hVcsB5bdLWqlaYjI2I4kGSxpAnVP7PYkCnAoB3vuHtC1EqbRfgZiQBgihzA=="],
|
|
24
24
|
|
|
25
25
|
"bun-types": ["bun-types@1.3.9", "", { "dependencies": { "@types/node": "*" } }, "sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg=="],
|
|
26
26
|
|
|
27
|
+
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
|
28
|
+
|
|
27
29
|
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
28
30
|
|
|
29
31
|
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
package/example/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|