@keyv/mongo 6.0.0-alpha.1 → 6.0.0-alpha.3
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.cjs +3 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -169,7 +169,7 @@ var KeyvMongo = class extends import_hookified.Hookified {
|
|
|
169
169
|
* @param options - Additional configuration options that override the first parameter.
|
|
170
170
|
*/
|
|
171
171
|
constructor(url, options) {
|
|
172
|
-
super();
|
|
172
|
+
super({ throwOnEmptyListeners: false });
|
|
173
173
|
let mergedOptions = {};
|
|
174
174
|
if (typeof url === "string") {
|
|
175
175
|
this._url = url;
|
|
@@ -512,7 +512,7 @@ var KeyvMongo = class extends import_hookified.Hookified {
|
|
|
512
512
|
const namespaceValue = namespace ?? "";
|
|
513
513
|
if (this._useGridFS) {
|
|
514
514
|
const gridIterator = client.store.find({ "metadata.namespace": { $eq: namespaceValue } }).map(async (x) => {
|
|
515
|
-
const prefixedKey =
|
|
515
|
+
const prefixedKey = x.filename;
|
|
516
516
|
const stream = client.bucket.openDownloadStream(x._id);
|
|
517
517
|
const data = await new Promise((resolve) => {
|
|
518
518
|
const resp = [];
|
|
@@ -532,8 +532,7 @@ var KeyvMongo = class extends import_hookified.Hookified {
|
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
534
|
const iterator = client.store.find({ namespace: { $eq: namespaceValue } }).map((x) => {
|
|
535
|
-
|
|
536
|
-
return [prefixedKey, x.value];
|
|
535
|
+
return [x.key, x.value];
|
|
537
536
|
});
|
|
538
537
|
yield* iterator;
|
|
539
538
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hookified } from 'hookified';
|
|
2
|
-
import Keyv, {
|
|
2
|
+
import Keyv, { KeyvStorageAdapter, StoredData } from 'keyv';
|
|
3
3
|
import { GridFSBucket, Collection, Db, MongoClient, ReadPreference, MongoClientOptions } from 'mongodb';
|
|
4
4
|
|
|
5
5
|
type Options = {
|
|
@@ -23,7 +23,7 @@ type KeyvMongoConnect = {
|
|
|
23
23
|
* MongoDB storage adapter for Keyv.
|
|
24
24
|
* Provides a persistent key-value store using MongoDB as the backend.
|
|
25
25
|
*/
|
|
26
|
-
declare class KeyvMongo extends Hookified implements
|
|
26
|
+
declare class KeyvMongo extends Hookified implements KeyvStorageAdapter {
|
|
27
27
|
/**
|
|
28
28
|
* The MongoDB connection URI.
|
|
29
29
|
* @default 'mongodb://127.0.0.1:27017'
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hookified } from 'hookified';
|
|
2
|
-
import Keyv, {
|
|
2
|
+
import Keyv, { KeyvStorageAdapter, StoredData } from 'keyv';
|
|
3
3
|
import { GridFSBucket, Collection, Db, MongoClient, ReadPreference, MongoClientOptions } from 'mongodb';
|
|
4
4
|
|
|
5
5
|
type Options = {
|
|
@@ -23,7 +23,7 @@ type KeyvMongoConnect = {
|
|
|
23
23
|
* MongoDB storage adapter for Keyv.
|
|
24
24
|
* Provides a persistent key-value store using MongoDB as the backend.
|
|
25
25
|
*/
|
|
26
|
-
declare class KeyvMongo extends Hookified implements
|
|
26
|
+
declare class KeyvMongo extends Hookified implements KeyvStorageAdapter {
|
|
27
27
|
/**
|
|
28
28
|
* The MongoDB connection URI.
|
|
29
29
|
* @default 'mongodb://127.0.0.1:27017'
|
package/dist/index.js
CHANGED
|
@@ -136,7 +136,7 @@ var KeyvMongo = class extends Hookified {
|
|
|
136
136
|
* @param options - Additional configuration options that override the first parameter.
|
|
137
137
|
*/
|
|
138
138
|
constructor(url, options) {
|
|
139
|
-
super();
|
|
139
|
+
super({ throwOnEmptyListeners: false });
|
|
140
140
|
let mergedOptions = {};
|
|
141
141
|
if (typeof url === "string") {
|
|
142
142
|
this._url = url;
|
|
@@ -479,7 +479,7 @@ var KeyvMongo = class extends Hookified {
|
|
|
479
479
|
const namespaceValue = namespace ?? "";
|
|
480
480
|
if (this._useGridFS) {
|
|
481
481
|
const gridIterator = client.store.find({ "metadata.namespace": { $eq: namespaceValue } }).map(async (x) => {
|
|
482
|
-
const prefixedKey =
|
|
482
|
+
const prefixedKey = x.filename;
|
|
483
483
|
const stream = client.bucket.openDownloadStream(x._id);
|
|
484
484
|
const data = await new Promise((resolve) => {
|
|
485
485
|
const resp = [];
|
|
@@ -499,8 +499,7 @@ var KeyvMongo = class extends Hookified {
|
|
|
499
499
|
return;
|
|
500
500
|
}
|
|
501
501
|
const iterator = client.store.find({ namespace: { $eq: namespaceValue } }).map((x) => {
|
|
502
|
-
|
|
503
|
-
return [prefixedKey, x.value];
|
|
502
|
+
return [x.key, x.value];
|
|
504
503
|
});
|
|
505
504
|
yield* iterator;
|
|
506
505
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/mongo",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
4
4
|
"description": "MongoDB storage adapter for Keyv",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/jaredwray/keyv",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"hookified": "^
|
|
44
|
+
"hookified": "^2.0.0",
|
|
45
45
|
"mongodb": "^7.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"rimraf": "^6.1.2",
|
|
52
52
|
"tsd": "^0.33.0",
|
|
53
53
|
"vitest": "^4.0.16",
|
|
54
|
-
"@keyv/test-suite": "^6.0.0-alpha.
|
|
54
|
+
"@keyv/test-suite": "^6.0.0-alpha.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"keyv": "^6.0.0-alpha.
|
|
57
|
+
"keyv": "^6.0.0-alpha.3"
|
|
58
58
|
},
|
|
59
59
|
"tsd": {
|
|
60
60
|
"directory": "test"
|