lakutata 2.0.65 → 2.0.67

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.
Files changed (213) hide show
  1. package/com/cacher.cjs +1 -1
  2. package/com/cacher.d.ts +4 -4
  3. package/com/cacher.mjs +1 -1
  4. package/com/database.cjs +0 -2
  5. package/com/database.d.ts +4 -4
  6. package/com/database.mjs +0 -2
  7. package/com/docker.d.ts +5 -5
  8. package/com/entrypoint.cjs +3 -1
  9. package/com/entrypoint.d.ts +2 -2
  10. package/com/entrypoint.mjs +3 -1
  11. package/com/logger.d.ts +1 -1
  12. package/com/monitor.d.ts +2 -2
  13. package/decorator/asst.d.ts +1 -1
  14. package/decorator/ctrl.cjs +3 -1
  15. package/decorator/ctrl.d.ts +4 -4
  16. package/decorator/ctrl.mjs +3 -1
  17. package/decorator/di.d.ts +3 -3
  18. package/decorator/dto.d.ts +3 -3
  19. package/decorator/orm.cjs +86 -88
  20. package/decorator/orm.d.ts +51 -75
  21. package/decorator/orm.mjs +44 -46
  22. package/helper.cjs +24 -18
  23. package/helper.d.ts +129 -3
  24. package/helper.mjs +6 -2
  25. package/lakutata.cjs +3 -1
  26. package/lakutata.d.ts +10 -10
  27. package/lakutata.mjs +3 -1
  28. package/orm.cjs +1075 -112
  29. package/orm.d.ts +6 -6
  30. package/orm.mjs +1015 -17
  31. package/package.json +1 -1
  32. package/provider/database.cjs +0 -2
  33. package/provider/database.d.ts +4 -4
  34. package/provider/database.mjs +0 -2
  35. package/provider/passwordHash.d.ts +1 -1
  36. package/src/components/Database.cjs +0 -2
  37. package/src/components/Database.mjs +0 -2
  38. package/src/components/cacher/Cacher.cjs +1 -1
  39. package/src/components/cacher/Cacher.mjs +1 -1
  40. package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +1 -1
  41. package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +1 -1
  42. package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.cjs +2 -2
  43. package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.mjs +2 -2
  44. package/src/components/cacher/adapters/CreateMongoCacheAdapter.cjs +2 -2
  45. package/src/components/cacher/adapters/CreateMongoCacheAdapter.mjs +2 -2
  46. package/src/components/cacher/adapters/CreateMysqlCacheAdapter.cjs +2 -2
  47. package/src/components/cacher/adapters/CreateMysqlCacheAdapter.mjs +2 -2
  48. package/src/components/cacher/adapters/CreatePostgresCacheAdapter.cjs +2 -2
  49. package/src/components/cacher/adapters/CreatePostgresCacheAdapter.mjs +2 -2
  50. package/src/components/cacher/adapters/CreateRedisCacheAdapter.cjs +2 -2
  51. package/src/components/cacher/adapters/CreateRedisCacheAdapter.mjs +2 -2
  52. package/src/components/cacher/adapters/CreateSqliteCacheAdapter.cjs +2 -2
  53. package/src/components/cacher/adapters/CreateSqliteCacheAdapter.mjs +2 -2
  54. package/src/components/entrypoint/Entrypoint.cjs +3 -1
  55. package/src/components/entrypoint/Entrypoint.mjs +3 -1
  56. package/src/decorators/ctrl/CLIAction.cjs +7 -5
  57. package/src/decorators/ctrl/CLIAction.mjs +3 -1
  58. package/src/decorators/ctrl/HTTPAction.cjs +8 -6
  59. package/src/decorators/ctrl/HTTPAction.mjs +3 -1
  60. package/src/decorators/ctrl/ServiceAction.cjs +3 -1
  61. package/src/decorators/ctrl/ServiceAction.mjs +7 -5
  62. package/src/decorators/ctrl/http/DELETE.cjs +3 -1
  63. package/src/decorators/ctrl/http/DELETE.mjs +3 -1
  64. package/src/decorators/ctrl/http/GET.cjs +3 -1
  65. package/src/decorators/ctrl/http/GET.mjs +3 -1
  66. package/src/decorators/ctrl/http/HEAD.cjs +3 -1
  67. package/src/decorators/ctrl/http/HEAD.mjs +3 -1
  68. package/src/decorators/ctrl/http/OPTIONS.cjs +3 -1
  69. package/src/decorators/ctrl/http/OPTIONS.mjs +3 -1
  70. package/src/decorators/ctrl/http/PATCH.cjs +3 -1
  71. package/src/decorators/ctrl/http/PATCH.mjs +3 -1
  72. package/src/decorators/ctrl/http/POST.cjs +3 -1
  73. package/src/decorators/ctrl/http/POST.mjs +3 -1
  74. package/src/decorators/ctrl/http/PUT.cjs +3 -1
  75. package/src/decorators/ctrl/http/PUT.mjs +3 -1
  76. package/src/decorators/orm/AfterInsert.cjs +27 -7
  77. package/src/decorators/orm/AfterInsert.mjs +28 -6
  78. package/src/decorators/orm/AfterLoad.cjs +27 -7
  79. package/src/decorators/orm/AfterLoad.mjs +28 -6
  80. package/src/decorators/orm/AfterRecover.cjs +27 -7
  81. package/src/decorators/orm/AfterRecover.mjs +28 -6
  82. package/src/decorators/orm/AfterRemove.cjs +27 -7
  83. package/src/decorators/orm/AfterRemove.mjs +28 -6
  84. package/src/decorators/orm/AfterSoftRemove.cjs +27 -7
  85. package/src/decorators/orm/AfterSoftRemove.mjs +28 -6
  86. package/src/decorators/orm/AfterUpdate.cjs +27 -7
  87. package/src/decorators/orm/AfterUpdate.mjs +28 -6
  88. package/src/decorators/orm/BeforeInsert.cjs +27 -7
  89. package/src/decorators/orm/BeforeInsert.mjs +28 -6
  90. package/src/decorators/orm/BeforeRecover.cjs +27 -7
  91. package/src/decorators/orm/BeforeRecover.mjs +28 -6
  92. package/src/decorators/orm/BeforeRemove.cjs +27 -7
  93. package/src/decorators/orm/BeforeRemove.mjs +28 -6
  94. package/src/decorators/orm/BeforeSoftRemove.cjs +27 -7
  95. package/src/decorators/orm/BeforeSoftRemove.mjs +28 -6
  96. package/src/decorators/orm/BeforeUpdate.cjs +27 -7
  97. package/src/decorators/orm/BeforeUpdate.mjs +28 -6
  98. package/src/decorators/orm/Check.cjs +30 -7
  99. package/src/decorators/orm/Check.mjs +31 -6
  100. package/src/decorators/orm/ChildEntity.cjs +30 -7
  101. package/src/decorators/orm/ChildEntity.mjs +31 -6
  102. package/src/decorators/orm/Column.cjs +62 -7
  103. package/src/decorators/orm/Column.mjs +63 -6
  104. package/src/decorators/orm/CreateDateColumn.cjs +26 -7
  105. package/src/decorators/orm/CreateDateColumn.mjs +27 -6
  106. package/src/decorators/orm/DeleteDateColumn.cjs +26 -7
  107. package/src/decorators/orm/DeleteDateColumn.mjs +27 -6
  108. package/src/decorators/orm/Entity.cjs +36 -7
  109. package/src/decorators/orm/Entity.mjs +37 -6
  110. package/src/decorators/orm/EventSubscriber.cjs +23 -7
  111. package/src/decorators/orm/EventSubscriber.mjs +24 -6
  112. package/src/decorators/orm/Exclusion.cjs +30 -7
  113. package/src/decorators/orm/Exclusion.mjs +31 -6
  114. package/src/decorators/orm/Generated.cjs +25 -7
  115. package/src/decorators/orm/Generated.mjs +26 -6
  116. package/src/decorators/orm/Index.cjs +42 -7
  117. package/src/decorators/orm/Index.mjs +43 -6
  118. package/src/decorators/orm/JoinColumn.cjs +30 -7
  119. package/src/decorators/orm/JoinColumn.mjs +31 -6
  120. package/src/decorators/orm/JoinTable.cjs +31 -7
  121. package/src/decorators/orm/JoinTable.mjs +32 -6
  122. package/src/decorators/orm/ManyToMany.cjs +43 -7
  123. package/src/decorators/orm/ManyToMany.mjs +44 -6
  124. package/src/decorators/orm/ManyToOne.cjs +43 -7
  125. package/src/decorators/orm/ManyToOne.mjs +44 -6
  126. package/src/decorators/orm/ObjectIdColumn.cjs +29 -7
  127. package/src/decorators/orm/ObjectIdColumn.mjs +30 -6
  128. package/src/decorators/orm/OneToMany.cjs +35 -7
  129. package/src/decorators/orm/OneToMany.mjs +36 -6
  130. package/src/decorators/orm/OneToOne.cjs +43 -7
  131. package/src/decorators/orm/OneToOne.mjs +44 -6
  132. package/src/decorators/orm/PrimaryColumn.cjs +50 -7
  133. package/src/decorators/orm/PrimaryColumn.mjs +51 -6
  134. package/src/decorators/orm/PrimaryGeneratedColumn.cjs +55 -7
  135. package/src/decorators/orm/PrimaryGeneratedColumn.mjs +56 -6
  136. package/src/decorators/orm/RelationId.cjs +27 -7
  137. package/src/decorators/orm/RelationId.mjs +28 -6
  138. package/src/decorators/orm/TableInheritance.cjs +27 -7
  139. package/src/decorators/orm/TableInheritance.mjs +28 -6
  140. package/src/decorators/orm/Tree.cjs +25 -7
  141. package/src/decorators/orm/Tree.mjs +26 -6
  142. package/src/decorators/orm/TreeChildren.cjs +32 -7
  143. package/src/decorators/orm/TreeChildren.mjs +33 -6
  144. package/src/decorators/orm/TreeLevelColumn.cjs +26 -7
  145. package/src/decorators/orm/TreeLevelColumn.mjs +27 -6
  146. package/src/decorators/orm/TreeParent.cjs +32 -7
  147. package/src/decorators/orm/TreeParent.mjs +33 -6
  148. package/src/decorators/orm/Unique.cjs +45 -7
  149. package/src/decorators/orm/Unique.mjs +46 -6
  150. package/src/decorators/orm/UpdateDateColumn.cjs +26 -7
  151. package/src/decorators/orm/UpdateDateColumn.mjs +27 -6
  152. package/src/decorators/orm/VersionColumn.cjs +26 -7
  153. package/src/decorators/orm/VersionColumn.mjs +27 -6
  154. package/src/decorators/orm/ViewColumn.cjs +26 -7
  155. package/src/decorators/orm/ViewColumn.mjs +27 -6
  156. package/src/decorators/orm/ViewEntity.cjs +35 -7
  157. package/src/decorators/orm/ViewEntity.mjs +36 -6
  158. package/src/decorators/orm/VirtualColumn.cjs +43 -7
  159. package/src/decorators/orm/VirtualColumn.mjs +44 -6
  160. package/src/lib/base/internal/ControllerEntrypoint.cjs +70 -610
  161. package/src/lib/base/internal/ControllerEntrypoint.mjs +87 -627
  162. package/src/lib/base/internal/StringifyPattern.cjs +1 -1
  163. package/src/lib/base/internal/StringifyPattern.mjs +1 -1
  164. package/src/lib/core/Application.cjs +3 -1
  165. package/src/lib/core/Application.mjs +3 -1
  166. package/src/lib/helpers/MD5.cjs +1 -1
  167. package/src/lib/helpers/MD5.mjs +1 -1
  168. package/src/lib/helpers/SHA1.cjs +1 -1
  169. package/src/lib/helpers/SHA1.mjs +1 -1
  170. package/src/lib/helpers/SHA256.cjs +1 -1
  171. package/src/lib/helpers/SHA256.mjs +1 -1
  172. package/src/lib/helpers/SortArray.cjs +1 -1
  173. package/src/lib/helpers/SortArray.mjs +1 -1
  174. package/src/lib/helpers/UUID.cjs +45 -0
  175. package/src/lib/helpers/UUID.mjs +39 -0
  176. package/src/providers/Database.cjs +0 -2
  177. package/src/providers/Database.mjs +0 -2
  178. package/vendor/Package.122.cjs +13223 -16706
  179. package/vendor/Package.122.mjs +13498 -16881
  180. package/vendor/Package.19.cjs +184 -195
  181. package/vendor/Package.19.mjs +176 -187
  182. package/vendor/Package.610.cjs +297 -113
  183. package/vendor/Package.610.mjs +285 -97
  184. package/vendor/Package.611.cjs +85 -103
  185. package/vendor/Package.611.mjs +80 -98
  186. package/vendor/Package.612.cjs +100 -121
  187. package/vendor/Package.612.mjs +97 -120
  188. package/vendor/Package.613.cjs +196 -0
  189. package/vendor/Package.613.mjs +180 -0
  190. package/vendor/Package.64.cjs +511 -134
  191. package/vendor/Package.64.mjs +491 -134
  192. package/vendor/Package.65.cjs +140 -4118
  193. package/vendor/Package.65.mjs +140 -4126
  194. package/vendor/Package.66.cjs +4142 -692
  195. package/vendor/Package.66.mjs +4151 -689
  196. package/vendor/Package.67.cjs +571 -535
  197. package/vendor/Package.67.mjs +586 -528
  198. package/vendor/Package.68.cjs +633 -96
  199. package/vendor/Package.68.mjs +619 -94
  200. package/vendor/Package.69.cjs +96 -294
  201. package/vendor/Package.69.mjs +95 -295
  202. package/vendor/TypeDef.internal.1.d.ts +1 -1
  203. package/vendor/TypeDef.internal.10.d.ts +1 -1
  204. package/vendor/TypeDef.internal.11.d.ts +2 -2
  205. package/vendor/TypeDef.internal.12.d.ts +2 -2
  206. package/vendor/TypeDef.internal.13.d.ts +6 -6
  207. package/vendor/TypeDef.internal.3.d.ts +3 -3
  208. package/vendor/TypeDef.internal.4.d.ts +181 -347
  209. package/vendor/TypeDef.internal.5.d.ts +2 -2
  210. package/vendor/TypeDef.internal.6.d.ts +2 -2
  211. package/vendor/TypeDef.internal.7.d.ts +1 -1
  212. package/vendor/TypeDef.internal.8.d.ts +1 -1
  213. package/vendor/TypeDef.internal.9.d.ts +1 -1
@@ -6,336 +6,138 @@ Object.defineProperty(exports, Symbol.toStringTag, {
6
6
 
7
7
  const e = require("events");
8
8
 
9
- const t = require("buffer");
9
+ const t = require("memjs");
10
10
 
11
- const n = require("mongodb");
11
+ const s = require("./Package.67.cjs");
12
12
 
13
- const s = e => e && e.__esModule ? e : {
13
+ require("buffer");
14
+
15
+ const r = e => e && e.__esModule ? e : {
14
16
  default: e
15
17
  };
16
18
 
17
- const o = s(e);
19
+ const i = r(e);
18
20
 
19
- var a = new Set([ "url", "collection", "namespace", "serialize", "deserialize", "uri", "useGridFS", "dialect", "db" ]);
21
+ const a = r(t);
20
22
 
21
- var i = class extends o.default {
22
- ttlSupport=false;
23
- opts;
24
- connect;
23
+ var n = class extends i.default {
24
+ ttlSupport=true;
25
25
  namespace;
26
+ client;
27
+ opts;
26
28
  constructor(e, t) {
27
29
  super();
28
- e ??= {};
29
- if (typeof e === "string") {
30
- e = {
31
- url: e
32
- };
33
- }
34
- if (e.uri) {
35
- e = {
36
- url: e.uri,
37
- ...e
38
- };
39
- }
40
- this.opts = {
41
- url: "mongodb://127.0.0.1:27017",
42
- collection: "keyv",
43
- ...e,
30
+ t = {
31
+ ...typeof e === "string" ? {
32
+ uri: e
33
+ } : e,
44
34
  ...t
45
35
  };
46
- delete this.opts.emitErrors;
47
- const s = Object.fromEntries(Object.entries(this.opts).filter((([e]) => !a.has(e))));
48
- this.opts = Object.fromEntries(Object.entries(this.opts).filter((([e]) => a.has(e))));
49
- this.connect = new Promise((async (e, t) => {
50
- try {
51
- let t = "";
52
- if (this.opts.url) {
53
- t = this.opts.url;
54
- }
55
- const o = new n.MongoClient(t, s);
56
- await o.connect();
57
- const a = o.db(this.opts.db);
58
- if (this.opts.useGridFS) {
59
- const t = new n.GridFSBucket(a, {
60
- readPreference: this.opts.readPreference,
61
- bucketName: this.opts.collection
62
- });
63
- const s = a.collection(`${this.opts.collection}.files`);
64
- await s.createIndex({
65
- uploadDate: -1
66
- });
67
- await s.createIndex({
68
- "metadata.expiresAt": 1
69
- });
70
- await s.createIndex({
71
- "metadata.lastAccessed": 1
72
- });
73
- await s.createIndex({
74
- "metadata.filename": 1
75
- });
76
- e({
77
- bucket: t,
78
- store: s,
79
- db: a,
80
- mongoClient: o
81
- });
82
- } else {
83
- let t = "keyv";
84
- if (this.opts.collection) {
85
- t = this.opts.collection;
86
- }
87
- const n = a.collection(t);
88
- await n.createIndex({
89
- key: 1
90
- }, {
91
- unique: true,
92
- background: true
93
- });
94
- await n.createIndex({
95
- expiresAt: 1
96
- }, {
97
- expireAfterSeconds: 0,
98
- background: true
99
- });
100
- e({
101
- store: n,
102
- mongoClient: o
103
- });
104
- }
105
- } catch (e) {
106
- this.emit("error", e);
107
- }
108
- }));
36
+ if (t.uri && t.url === void 0) {
37
+ t.url = t.uri;
38
+ }
39
+ if (e === void 0) {
40
+ e = "localhost:11211";
41
+ t.url = t.uri = e;
42
+ }
43
+ this.opts = t;
44
+ this.client = a.default.Client.create(e, t);
45
+ }
46
+ _getNamespace() {
47
+ return `namespace:${this.namespace}`;
109
48
  }
110
49
  async get(e) {
111
- const n = await this.connect;
112
- if (this.opts.useGridFS) {
113
- await n.store.updateOne({
114
- filename: e
115
- }, {
116
- $set: {
117
- "metadata.lastAccessed": new Date
50
+ return new Promise(((t, r) => {
51
+ this.client.get(this.formatKey(e), ((e, i) => {
52
+ if (e) {
53
+ this.emit("error", e);
54
+ r(e);
55
+ } else {
56
+ let e;
57
+ if (i === null) {
58
+ e = {
59
+ value: void 0,
60
+ expires: 0
61
+ };
62
+ } else {
63
+ e = this.opts.deserialize ? this.opts.deserialize(i) : s.defaultDeserialize(i);
64
+ }
65
+ t(e);
118
66
  }
119
- });
120
- const s = n.bucket.openDownloadStreamByName(e);
121
- return new Promise((e => {
122
- const n = [];
123
- s.on("error", (() => {
124
- e(void 0);
125
- }));
126
- s.on("end", (() => {
127
- const s = t.Buffer.concat(n).toString("utf8");
128
- e(s);
129
- }));
130
- s.on("data", (e => {
131
- n.push(e);
132
- }));
133
67
  }));
134
- }
135
- const s = await n.store.findOne({
136
- key: {
137
- $eq: e
138
- }
139
- });
140
- if (!s) {
141
- return void 0;
142
- }
143
- return s.value;
68
+ }));
144
69
  }
145
70
  async getMany(e) {
146
- if (this.opts.useGridFS) {
147
- const t = [];
148
- for (const n of e) {
149
- t.push(this.get(n));
150
- }
151
- const n = await Promise.allSettled(t);
152
- const s = [];
153
- for (const e of n) {
154
- s.push(e.value);
155
- }
156
- return s;
71
+ const t = [];
72
+ for (const s of e) {
73
+ t.push(this.get(s));
157
74
  }
158
- const t = await this.connect;
159
- const n = await t.store.s.db.collection(this.opts.collection).find({
160
- key: {
161
- $in: e
75
+ return Promise.allSettled(t).then((e => {
76
+ const t = [];
77
+ for (const s of e) {
78
+ t.push(s.value);
162
79
  }
163
- }).project({
164
- _id: 0,
165
- value: 1,
166
- key: 1
167
- }).toArray();
168
- const s = [ ...e ];
169
- let o = 0;
170
- for (const t of e) {
171
- const e = n.findIndex((e => e.key === t));
172
- s[o] = e > -1 ? n[e].value : void 0;
173
- o++;
174
- }
175
- return s;
80
+ return t;
81
+ }));
176
82
  }
177
- async set(e, t, n) {
178
- const s = typeof n === "number" ? new Date(Date.now() + n) : null;
179
- if (this.opts.useGridFS) {
180
- const n = await this.connect;
181
- const o = n.bucket.openUploadStream(e, {
182
- metadata: {
183
- expiresAt: s,
184
- lastAccessed: new Date
185
- }
186
- });
187
- return new Promise((e => {
188
- o.on("finish", (() => {
189
- e(o);
190
- }));
191
- o.end(t);
192
- }));
83
+ async set(e, t, s) {
84
+ const r = {};
85
+ if (s !== void 0) {
86
+ r.expires = r.ttl = Math.floor(s / 1e3);
193
87
  }
194
- const o = await this.connect;
195
- await o.store.updateOne({
196
- key: {
197
- $eq: e
198
- }
199
- }, {
200
- $set: {
201
- key: e,
202
- value: t,
203
- expiresAt: s
204
- }
205
- }, {
206
- upsert: true
207
- });
88
+ await this.client.set(this.formatKey(e), t, r);
208
89
  }
209
90
  async delete(e) {
210
- if (typeof e !== "string") {
211
- return false;
212
- }
213
- const t = await this.connect;
214
- if (this.opts.useGridFS) {
215
- try {
216
- const s = t.db;
217
- const o = new n.GridFSBucket(s, {
218
- bucketName: this.opts.collection
219
- });
220
- const a = await o.find({
221
- filename: e
222
- }).toArray();
223
- await t.bucket.delete(a[0]._id);
224
- return true;
225
- } catch {
226
- return false;
227
- }
228
- }
229
- const s = await t.store.deleteOne({
230
- key: {
231
- $eq: e
232
- }
233
- });
234
- return s.deletedCount > 0;
91
+ return new Promise(((t, s) => {
92
+ this.client.delete(this.formatKey(e), ((e, r) => {
93
+ if (e) {
94
+ this.emit("error", e);
95
+ s(e);
96
+ } else {
97
+ t(Boolean(r));
98
+ }
99
+ }));
100
+ }));
235
101
  }
236
102
  async deleteMany(e) {
237
- const t = await this.connect;
238
- if (this.opts.useGridFS) {
239
- const s = t.db;
240
- const o = new n.GridFSBucket(s, {
241
- bucketName: this.opts.collection
242
- });
243
- const a = await o.find({
244
- filename: {
245
- $in: e
246
- }
247
- }).toArray();
248
- if (a.length === 0) {
249
- return false;
250
- }
251
- await Promise.all(a.map((async e => t.bucket.delete(e._id))));
252
- return true;
253
- }
254
- const s = await t.store.deleteMany({
255
- key: {
256
- $in: e
257
- }
258
- });
259
- return s.deletedCount > 0;
103
+ const t = e.map((async e => this.delete(e)));
104
+ const s = await Promise.allSettled(t);
105
+ return s.every((e => e.value === true));
260
106
  }
261
107
  async clear() {
262
- const e = await this.connect;
263
- if (this.opts.useGridFS) {
264
- try {
265
- await e.bucket.drop();
266
- } catch (e) {
267
- if (!(e instanceof n.MongoServerError && e.code === 26)) {
268
- throw e;
269
- }
270
- }
271
- }
272
- await e.store.deleteMany({
273
- key: {
274
- $regex: this.namespace ? `^${this.namespace}:*` : ""
275
- }
276
- });
277
- }
278
- async clearExpired() {
279
- if (!this.opts.useGridFS) {
280
- return false;
281
- }
282
- return this.connect.then((async e => {
283
- const t = e.db;
284
- const s = new n.GridFSBucket(t, {
285
- bucketName: this.opts.collection
286
- });
287
- return s.find({
288
- "metadata.expiresAt": {
289
- $lte: new Date(Date.now())
108
+ return new Promise(((e, t) => {
109
+ this.client.flush((s => {
110
+ if (s) {
111
+ this.emit("error", s);
112
+ t(s);
113
+ } else {
114
+ e(void 0);
290
115
  }
291
- }).toArray().then((async t => Promise.all(t.map((async t => e.bucket.delete(t._id)))).then((() => true))));
116
+ }));
292
117
  }));
293
118
  }
294
- async clearUnusedFor(e) {
295
- if (!this.opts.useGridFS) {
296
- return false;
119
+ formatKey(e) {
120
+ let t = e;
121
+ if (this.namespace) {
122
+ t = this.namespace.trim() + ":" + e.trim();
297
123
  }
298
- const t = await this.connect;
299
- const s = t.db;
300
- const o = new n.GridFSBucket(s, {
301
- bucketName: this.opts.collection
302
- });
303
- const a = await o.find({
304
- "metadata.lastAccessed": {
305
- $lte: new Date(Date.now() - e * 1e3)
306
- }
307
- }).toArray();
308
- await Promise.all(a.map((async e => t.bucket.delete(e._id))));
309
- return true;
310
- }
311
- async* iterator(e) {
312
- const t = await this.connect;
313
- const n = new RegExp(`^${e ? e + ":" : ".*"}`);
314
- const s = this.opts.useGridFS ? t.store.find({
315
- filename: n
316
- }).map((async e => [ e.filename, await this.get(e.filename) ])) : t.store.find({
317
- key: n
318
- }).map((e => [ e.key, e.value ]));
319
- yield* s;
124
+ return t;
320
125
  }
321
126
  async has(e) {
322
- const t = await this.connect;
323
- const n = {
324
- [this.opts.useGridFS ? "filename" : "key"]: {
325
- $eq: e
326
- }
327
- };
328
- const s = await t.store.count(n);
329
- return s !== 0;
330
- }
331
- async disconnect() {
332
- const e = await this.connect;
333
- await e.mongoClient.close();
127
+ return new Promise((t => {
128
+ this.client.get(this.formatKey(e), ((e, s) => {
129
+ if (e) {
130
+ t(false);
131
+ } else {
132
+ t(s !== null);
133
+ }
134
+ }));
135
+ }));
334
136
  }
335
137
  };
336
138
 
337
- var c = i;
139
+ var o = n;
338
140
 
339
- exports.KeyvMongo = i;
141
+ exports.KeyvMemcache = n;
340
142
 
341
- exports.default = c;
143
+ exports.default = o;