ueberdb2 4.1.6 → 4.1.8
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/databases/couch_db.js +4 -10
- package/dist/databases/mongodb_db.js +34 -26
- package/package.json +4 -4
|
@@ -56,20 +56,14 @@ const Database = class Couch_db extends AbstractDatabase_1.default {
|
|
|
56
56
|
}
|
|
57
57
|
const client = (0, nano_1.default)(coudhDBSettings);
|
|
58
58
|
try {
|
|
59
|
-
|
|
60
|
-
await client.db.get(this.settings.database);
|
|
61
|
-
}
|
|
59
|
+
await client.db.get(this.settings.database);
|
|
62
60
|
}
|
|
63
61
|
catch (err) {
|
|
64
62
|
if (err.statusCode !== 404)
|
|
65
63
|
throw err;
|
|
66
|
-
|
|
67
|
-
await client.db.create(this.settings.database);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (this.settings.database != null) {
|
|
71
|
-
this.db = client.use(this.settings.database);
|
|
64
|
+
await client.db.create(this.settings.database);
|
|
72
65
|
}
|
|
66
|
+
this.db = client.use(this.settings.database);
|
|
73
67
|
}
|
|
74
68
|
async get(key) {
|
|
75
69
|
let doc;
|
|
@@ -169,7 +163,7 @@ const Database = class Couch_db extends AbstractDatabase_1.default {
|
|
|
169
163
|
set._deleted = true;
|
|
170
164
|
setters.push(set);
|
|
171
165
|
}
|
|
172
|
-
await this.db
|
|
166
|
+
await this.db.bulk({ docs: setters });
|
|
173
167
|
}
|
|
174
168
|
async close() {
|
|
175
169
|
this.db = null;
|
|
@@ -18,8 +18,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Database = void 0;
|
|
21
22
|
const AbstractDatabase_1 = __importDefault(require("../lib/AbstractDatabase"));
|
|
22
|
-
|
|
23
|
+
const mongodb_1 = require("mongodb");
|
|
24
|
+
const Database = class extends AbstractDatabase_1.default {
|
|
23
25
|
interval;
|
|
24
26
|
database;
|
|
25
27
|
client;
|
|
@@ -49,23 +51,25 @@ exports.Database = class extends AbstractDatabase_1.default {
|
|
|
49
51
|
}, 10000);
|
|
50
52
|
}
|
|
51
53
|
init(callback) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
callback(
|
|
54
|
+
mongodb_1.MongoClient.connect(this.settings.url).then((v) => {
|
|
55
|
+
this.client = v;
|
|
56
|
+
this.database = v.db(this.settings.database);
|
|
57
|
+
this.collection = this.database.collection(this.settings.collection);
|
|
58
|
+
callback(null);
|
|
59
|
+
})
|
|
60
|
+
.catch((v) => {
|
|
61
|
+
callback(v);
|
|
60
62
|
});
|
|
61
63
|
this.schedulePing();
|
|
62
64
|
}
|
|
63
65
|
get(key, callback) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
this.collection.findOne({ _id: key })
|
|
68
|
+
.then((v) => {
|
|
69
|
+
callback(null, v && v.value);
|
|
70
|
+
}).catch(v => {
|
|
71
|
+
console.log(v);
|
|
72
|
+
callback(v);
|
|
69
73
|
});
|
|
70
74
|
this.schedulePing();
|
|
71
75
|
}
|
|
@@ -79,15 +83,13 @@ exports.Database = class extends AbstractDatabase_1.default {
|
|
|
79
83
|
// @ts-ignore
|
|
80
84
|
selector.$and.push({ _id: { $not: { $regex: `${notKey.replace(/\*/g, '')}` } } });
|
|
81
85
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
});
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
this.collection.find(selector).map((i) => i._id)
|
|
88
|
+
.toArray()
|
|
89
|
+
.then(r => {
|
|
90
|
+
callback(null, r);
|
|
91
|
+
})
|
|
92
|
+
.catch(v => callback(v));
|
|
91
93
|
this.schedulePing();
|
|
92
94
|
}
|
|
93
95
|
set(key, value, callback) {
|
|
@@ -95,12 +97,17 @@ exports.Database = class extends AbstractDatabase_1.default {
|
|
|
95
97
|
callback('Your Key can only be 100 chars');
|
|
96
98
|
}
|
|
97
99
|
else {
|
|
98
|
-
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
this.collection.updateMany({ _id: key }, { $set: { value } }, { upsert: true })
|
|
102
|
+
.then(v => callback(null)).catch(v => callback(v));
|
|
99
103
|
}
|
|
100
104
|
this.schedulePing();
|
|
101
105
|
}
|
|
102
106
|
remove(key, callback) {
|
|
103
|
-
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
this.collection.deleteOne({ _id: key })
|
|
109
|
+
.then(r => callback(null, r))
|
|
110
|
+
.catch(v => callback(v));
|
|
104
111
|
this.schedulePing();
|
|
105
112
|
}
|
|
106
113
|
doBulk(bulk, callback) {
|
|
@@ -122,6 +129,7 @@ exports.Database = class extends AbstractDatabase_1.default {
|
|
|
122
129
|
}
|
|
123
130
|
close(callback) {
|
|
124
131
|
this.clearPing();
|
|
125
|
-
this.client.close(callback);
|
|
132
|
+
this.client.close().then(r => callback(r));
|
|
126
133
|
}
|
|
127
134
|
};
|
|
135
|
+
exports.Database = Database;
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dirty": "^1.1.3",
|
|
27
27
|
"elasticsearch8": "npm:@elastic/elasticsearch@^8.8.1",
|
|
28
28
|
"eslint-plugin-import": "^2.26.0",
|
|
29
|
-
"mongodb": "^
|
|
29
|
+
"mongodb": "^5.7.0",
|
|
30
30
|
"mssql": "^9.1.1",
|
|
31
31
|
"mysql": "2.18.1",
|
|
32
32
|
"nano": "^10.1.2",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/async": "^3.2.20",
|
|
44
44
|
"@types/mocha": "^10.0.1",
|
|
45
|
-
"@types/mongodb": "^4.0.7",
|
|
46
45
|
"@types/mssql": "^8.1.2",
|
|
46
|
+
"@types/mongodb": "^4.0.7",
|
|
47
47
|
"@types/mysql": "^2.15.21",
|
|
48
|
-
"@types/node": "^20.
|
|
48
|
+
"@types/node": "^20.4.0",
|
|
49
49
|
"@types/pg": "^8.10.2",
|
|
50
50
|
"@types/rethinkdb": "^2.3.17",
|
|
51
51
|
"cli-table": "^0.3.11",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"url": "https://github.com/ether/ueberDB.git"
|
|
64
64
|
},
|
|
65
65
|
"main": "./dist/index",
|
|
66
|
-
"version": "4.1.
|
|
66
|
+
"version": "4.1.8",
|
|
67
67
|
"bugs": {
|
|
68
68
|
"url": "https://github.com/ether/ueberDB/issues"
|
|
69
69
|
},
|