w-orm-mongodb 1.1.40 → 1.1.41

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/README.md CHANGED
@@ -236,6 +236,43 @@ delAll(find) → { n, nDeleted, ok }
236
236
 
237
237
  `del`對未帶有效`id`者不送查詢條件,直接回`ok: 0`並附`err`,以免`undefined`經序列化為`null`而誤刪`id`為`null`之數據。
238
238
 
239
+ ## Events
240
+
241
+ 操作物件為`EventEmitter`,發出`change`與`error`兩種事件,供於單一處集中觀察資料異動與失敗,不必在每個呼叫點各自包裝。
242
+
243
+ ```alias
244
+ change (mode, data, res) 資料實際異動成功後,整批一次
245
+ error (mode, data, err) 整批性錯誤於 reject 前;逐筆失敗於該筆定案後,每筆一次
246
+
247
+ mode 函數名稱,如 'insert'、'save'、'del'、'delAll'、'select'、'selectByPk'、'insertGfs' 等
248
+ data 輸入數據,無輸入數據者(如 delAll、select、selectByPk)為 null
249
+ err 錯誤訊息字串
250
+ ```
251
+
252
+ ```alias
253
+ let wo = WOrm(opt)
254
+
255
+ wo.on('change', function(mode, data, res) {
256
+ console.log('change', mode, res)
257
+ })
258
+
259
+ wo.on('error', function(mode, data, err) {
260
+ console.log('error', mode, err)
261
+ })
262
+ ```
263
+
264
+ **事件僅為附加通知,不承擔任何回傳義務。** 凡經由事件送出之資訊,必同時經由正規管道送達——整批性錯誤經`Promise.reject`,逐筆失敗經該筆之`err`欄位,操作結果經 resolve 值。把全部事件移除之後,呼叫端仍能取得完整資訊。
265
+
266
+ **操作行為不因監聽者之有無而改變。** 同一份程式碼、同一組輸入,於有註冊監聽與未註冊監聽兩種情況下,回傳值與 resolve/reject 之選擇完全相同。本套件之`EventEmitter`採`eventemitter3`(`wsemi`之`evem()`),其於`'error'`無監聽者時僅回傳`false`而不拋出;Node 內建之`events.EventEmitter`具「`'error'`無監聽者時將錯誤拋出」之語義,故不採用。
267
+
268
+ 訂閱函數自身拋錯亦不影響本次操作之結果——每一處`emit`皆以 try/catch 包覆。
269
+
270
+ **正常結果不發出`error`。** `insert`全數已存在、`save`合併後內容相同而未寫入、`del`主鍵未命中、`delAll`條件無命中、`selectByPk`查無數據,皆為正常結果而非錯誤。
271
+
272
+ **收到`error`不表示該次呼叫失敗。** 逐筆失敗時整批仍 resolve,欲判斷整批成敗仍依上方「判讀準則」。
273
+
274
+ `save`於逐筆插入時另發出`mode`為`'insert'`之`change`事件,供區辨新增與更新。讀取函數(`select`、`selectByPk`、`selectByPkGfs`)不發出`change`。
275
+
239
276
  ## Primary key
240
277
 
241
278
  本套件之主鍵欄位固定為`id`,尚未支援由呼叫端指定。`id`為無業務語義之識別碼。
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * w-orm-mongodb v1.1.40
2
+ * w-orm-mongodb v1.1.41
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("events"),require("mongodb"),require("stream")):"function"==typeof define&&define.amd?define(["events","mongodb","stream"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-mongodb"]=e(t.events,t.mongodb,t.stream)}(this,(function(t,e,r){"use strict";function n(t,e){return t===e||t!=t&&e!=e}function o(t,e){for(var r=t.length;r--;)if(n(t[r][0],e))return r;return-1}var u=Array.prototype.splice;function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i.prototype.clear=function(){this.__data__=[],this.size=0},i.prototype.delete=function(t){var e=this.__data__,r=o(e,t);return!(r<0)&&(r==e.length-1?e.pop():u.call(e,r,1),--this.size,!0)},i.prototype.get=function(t){var e=this.__data__,r=o(e,t);return r<0?void 0:e[r][1]},i.prototype.has=function(t){return o(this.__data__,t)>-1},i.prototype.set=function(t,e){var r=this.__data__,n=o(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var c="object"==typeof global&&global&&global.Object===Object&&global,a="object"==typeof self&&self&&self.Object===Object&&self,l=c||a||Function("return this")(),f=l.Symbol,s=Object.prototype,d=s.hasOwnProperty,v=s.toString,p=f?f.toStringTag:void 0;var b=Object.prototype.toString;var y="[object Null]",h="[object Undefined]",j=f?f.toStringTag:void 0;function g(t){return null==t?void 0===t?h:y:j&&j in Object(t)?function(t){var e=d.call(t,p),r=t[p];try{t[p]=void 0;var n=!0}catch(t){}var o=v.call(t);return n&&(e?t[p]=r:delete t[p]),o}(t):function(t){return b.call(t)}(t)}function _(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var w="[object AsyncFunction]",m="[object Function]",O="[object GeneratorFunction]",A="[object Proxy]";function S(t){if(!_(t))return!1;var e=g(t);return e==m||e==O||e==w||e==A}var k,P=l["__core-js_shared__"],x=(k=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"";var z=Function.prototype.toString;function B(t){if(null!=t){try{return z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var I=/^\[object .+?Constructor\]$/,E=Function.prototype,M=Object.prototype,F=E.toString,D=M.hasOwnProperty,$=RegExp("^"+F.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function N(t){return!(!_(t)||(e=t,x&&x in e))&&(S(t)?$:I).test(B(t));var e}function U(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return N(r)?r:void 0}var C=U(l,"Map"),G=U(Object,"create");var T=Object.prototype.hasOwnProperty;var R=Object.prototype.hasOwnProperty;function q(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function L(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function V(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}q.prototype.clear=function(){this.__data__=G?G(null):{},this.size=0},q.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},q.prototype.get=function(t){var e=this.__data__;if(G){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return T.call(e,t)?e[t]:void 0},q.prototype.has=function(t){var e=this.__data__;return G?void 0!==e[t]:R.call(e,t)},q.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=G&&void 0===e?"__lodash_hash_undefined__":e,this},V.prototype.clear=function(){this.size=0,this.__data__={hash:new q,map:new(C||i),string:new q}},V.prototype.delete=function(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e},V.prototype.get=function(t){return L(this,t).get(t)},V.prototype.has=function(t){return L(this,t).has(t)},V.prototype.set=function(t,e){var r=L(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function W(t){var e=this.__data__=new i(t);this.size=e.size}function H(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}W.prototype.clear=function(){this.__data__=new i,this.size=0},W.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},W.prototype.get=function(t){return this.__data__.get(t)},W.prototype.has=function(t){return this.__data__.has(t)},W.prototype.set=function(t,e){var r=this.__data__;if(r instanceof i){var n=r.__data__;if(!C||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new V(n)}return r.set(t,e),this.size=r.size,this};var J=function(){try{var t=U(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),K=J;function Q(t,e,r){"__proto__"==e&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var X=Object.prototype.hasOwnProperty;function Y(t,e,r){var o=t[e];X.call(t,e)&&n(o,r)&&(void 0!==r||e in t)||Q(t,e,r)}function Z(t,e,r,n){var o=!r;r||(r={});for(var u=-1,i=e.length;++u<i;){var c=e[u],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?Q(r,c,a):Y(r,c,a)}return r}function tt(t){return null!=t&&"object"==typeof t}function et(t){return tt(t)&&"[object Arguments]"==g(t)}var rt=Object.prototype,nt=rt.hasOwnProperty,ot=rt.propertyIsEnumerable,ut=et(function(){return arguments}())?et:function(t){return tt(t)&&nt.call(t,"callee")&&!ot.call(t,"callee")},it=ut,ct=Array.isArray;var at="object"==typeof exports&&exports&&!exports.nodeType&&exports,lt=at&&"object"==typeof module&&module&&!module.nodeType&&module,ft=lt&&lt.exports===at?l.Buffer:void 0,st=(ft?ft.isBuffer:void 0)||function(){return!1},dt=9007199254740991,vt=/^(?:0|[1-9]\d*)$/;function pt(t,e){var r=typeof t;return!!(e=null==e?dt:e)&&("number"==r||"symbol"!=r&&vt.test(t))&&t>-1&&t%1==0&&t<e}var bt=9007199254740991;function yt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=bt}var ht={};function jt(t){return function(e){return t(e)}}ht["[object Float32Array]"]=ht["[object Float64Array]"]=ht["[object Int8Array]"]=ht["[object Int16Array]"]=ht["[object Int32Array]"]=ht["[object Uint8Array]"]=ht["[object Uint8ClampedArray]"]=ht["[object Uint16Array]"]=ht["[object Uint32Array]"]=!0,ht["[object Arguments]"]=ht["[object Array]"]=ht["[object ArrayBuffer]"]=ht["[object Boolean]"]=ht["[object DataView]"]=ht["[object Date]"]=ht["[object Error]"]=ht["[object Function]"]=ht["[object Map]"]=ht["[object Number]"]=ht["[object Object]"]=ht["[object RegExp]"]=ht["[object Set]"]=ht["[object String]"]=ht["[object WeakMap]"]=!1;var gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,_t=gt&&"object"==typeof module&&module&&!module.nodeType&&module,wt=_t&&_t.exports===gt&&c.process,mt=function(){try{var t=_t&&_t.require&&_t.require("util").types;return t||wt&&wt.binding&&wt.binding("util")}catch(t){}}(),Ot=mt&&mt.isTypedArray,At=Ot?jt(Ot):function(t){return tt(t)&&yt(t.length)&&!!ht[g(t)]},St=Object.prototype.hasOwnProperty;function kt(t,e){var r=ct(t),n=!r&&it(t),o=!r&&!n&&st(t),u=!r&&!n&&!o&&At(t),i=r||n||o||u,c=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=c.length;for(var l in t)!e&&!St.call(t,l)||i&&("length"==l||o&&("offset"==l||"parent"==l)||u&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||pt(l,a))||c.push(l);return c}var Pt=Object.prototype;function xt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Pt)}function zt(t,e){return function(r){return t(e(r))}}var Bt=zt(Object.keys,Object),It=Object.prototype.hasOwnProperty;function Et(t){if(!xt(t))return Bt(t);var e=[];for(var r in Object(t))It.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Mt(t){return null!=t&&yt(t.length)&&!S(t)}function Ft(t){return Mt(t)?kt(t):Et(t)}var Dt=Object.prototype.hasOwnProperty;function $t(t){if(!_(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=xt(t),r=[];for(var n in t)("constructor"!=n||!e&&Dt.call(t,n))&&r.push(n);return r}function Nt(t){return Mt(t)?kt(t,!0):$t(t)}var Ut="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ct=Ut&&"object"==typeof module&&module&&!module.nodeType&&module,Gt=Ct&&Ct.exports===Ut?l.Buffer:void 0,Tt=Gt?Gt.allocUnsafe:void 0;function Rt(){return[]}var qt=Object.prototype.propertyIsEnumerable,Lt=Object.getOwnPropertySymbols,Vt=Lt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,u=[];++r<n;){var i=t[r];e(i,r,t)&&(u[o++]=i)}return u}(Lt(t),(function(e){return qt.call(t,e)})))}:Rt,Wt=Vt;function Ht(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var Jt=zt(Object.getPrototypeOf,Object),Kt=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Ht(e,Wt(t)),t=Jt(t);return e}:Rt,Qt=Kt;function Xt(t,e,r){var n=e(t);return ct(t)?n:Ht(n,r(t))}function Yt(t){return Xt(t,Ft,Wt)}function Zt(t){return Xt(t,Nt,Qt)}var te=U(l,"DataView"),ee=U(l,"Promise"),re=U(l,"Set"),ne=U(l,"WeakMap"),oe="[object Map]",ue="[object Promise]",ie="[object Set]",ce="[object WeakMap]",ae="[object DataView]",le=B(te),fe=B(C),se=B(ee),de=B(re),ve=B(ne),pe=g;(te&&pe(new te(new ArrayBuffer(1)))!=ae||C&&pe(new C)!=oe||ee&&pe(ee.resolve())!=ue||re&&pe(new re)!=ie||ne&&pe(new ne)!=ce)&&(pe=function(t){var e=g(t),r="[object Object]"==e?t.constructor:void 0,n=r?B(r):"";if(n)switch(n){case le:return ae;case fe:return oe;case se:return ue;case de:return ie;case ve:return ce}return e});var be=pe,ye=Object.prototype.hasOwnProperty;var he=l.Uint8Array;function je(t){var e=new t.constructor(t.byteLength);return new he(e).set(new he(t)),e}var ge=/\w*$/;var _e=f?f.prototype:void 0,we=_e?_e.valueOf:void 0;var me="[object Boolean]",Oe="[object Date]",Ae="[object Map]",Se="[object Number]",ke="[object RegExp]",Pe="[object Set]",xe="[object String]",ze="[object Symbol]",Be="[object ArrayBuffer]",Ie="[object DataView]",Ee="[object Float32Array]",Me="[object Float64Array]",Fe="[object Int8Array]",De="[object Int16Array]",$e="[object Int32Array]",Ne="[object Uint8Array]",Ue="[object Uint8ClampedArray]",Ce="[object Uint16Array]",Ge="[object Uint32Array]";function Te(t,e,r){var n,o,u,i=t.constructor;switch(e){case Be:return je(t);case me:case Oe:return new i(+t);case Ie:return function(t,e){var r=e?je(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case Ee:case Me:case Fe:case De:case $e:case Ne:case Ue:case Ce:case Ge:return function(t,e){var r=e?je(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case Ae:return new i;case Se:case xe:return new i(t);case ke:return(u=new(o=t).constructor(o.source,ge.exec(o))).lastIndex=o.lastIndex,u;case Pe:return new i;case ze:return n=t,we?Object(we.call(n)):{}}}var Re=Object.create,qe=function(){function t(){}return function(e){if(!_(e))return{};if(Re)return Re(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Le=qe;var Ve=mt&&mt.isMap,We=Ve?jt(Ve):function(t){return tt(t)&&"[object Map]"==be(t)};var He=mt&&mt.isSet,Je=He?jt(He):function(t){return tt(t)&&"[object Set]"==be(t)},Ke=1,Qe=2,Xe=4,Ye="[object Arguments]",Ze="[object Function]",tr="[object GeneratorFunction]",er="[object Object]",rr={};function nr(t,e,r,n,o,u){var i,c=e&Ke,a=e&Qe,l=e&Xe;if(r&&(i=o?r(t,n,o,u):r(t)),void 0!==i)return i;if(!_(t))return t;var f=ct(t);if(f){if(i=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&ye.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,i)}else{var s=be(t),d=s==Ze||s==tr;if(st(t))return function(t,e){if(e)return t.slice();var r=t.length,n=Tt?Tt(r):new t.constructor(r);return t.copy(n),n}(t,c);if(s==er||s==Ye||d&&!o){if(i=a||d?{}:function(t){return"function"!=typeof t.constructor||xt(t)?{}:Le(Jt(t))}(t),!c)return a?function(t,e){return Z(t,Qt(t),e)}(t,function(t,e){return t&&Z(e,Nt(e),t)}(i,t)):function(t,e){return Z(t,Wt(t),e)}(t,function(t,e){return t&&Z(e,Ft(e),t)}(i,t))}else{if(!rr[s])return o?t:{};i=Te(t,s,c)}}u||(u=new W);var v=u.get(t);if(v)return v;u.set(t,i),Je(t)?t.forEach((function(n){i.add(nr(n,e,r,n,t,u))})):We(t)&&t.forEach((function(n,o){i.set(o,nr(n,e,r,o,t,u))}));var p=f?void 0:(l?a?Zt:Yt:a?Nt:Ft)(t);return H(p||t,(function(n,o){p&&(n=t[o=n]),Y(i,o,nr(n,e,r,o,t,u))})),i}rr[Ye]=rr["[object Array]"]=rr["[object ArrayBuffer]"]=rr["[object DataView]"]=rr["[object Boolean]"]=rr["[object Date]"]=rr["[object Float32Array]"]=rr["[object Float64Array]"]=rr["[object Int8Array]"]=rr["[object Int16Array]"]=rr["[object Int32Array]"]=rr["[object Map]"]=rr["[object Number]"]=rr[er]=rr["[object RegExp]"]=rr["[object Set]"]=rr["[object String]"]=rr["[object Symbol]"]=rr["[object Uint8Array]"]=rr["[object Uint8ClampedArray]"]=rr["[object Uint16Array]"]=rr["[object Uint32Array]"]=!0,rr["[object Error]"]=rr[Ze]=rr["[object WeakMap]"]=!1;var or=1,ur=4;function ir(t){return nr(t,or|ur)}function cr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(!e(t[r],r,t))return!1;return!0}var ar,lr=function(t,e,r){for(var n=-1,o=Object(t),u=r(t),i=u.length;i--;){var c=u[ar?i:++n];if(!1===e(o[c],c,o))break}return t};var fr=function(t,e){return function(r,n){if(null==r)return r;if(!Mt(r))return t(r,n);for(var o=r.length,u=e?o:-1,i=Object(r);(e?u--:++u<o)&&!1!==n(i[u],u,i););return r}}((function(t,e){return t&&lr(t,e,Ft)})),sr=fr;function dr(t,e){var r=!0;return sr(t,(function(t,n,o){return r=!!e(t,n,o)})),r}function vr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new V;++e<r;)this.add(t[e])}function pr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}vr.prototype.add=vr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},vr.prototype.has=function(t){return this.__data__.has(t)};var br=1,yr=2;function hr(t,e,r,n,o,u){var i=r&br,c=t.length,a=e.length;if(c!=a&&!(i&&a>c))return!1;var l=u.get(t),f=u.get(e);if(l&&f)return l==e&&f==t;var s=-1,d=!0,v=r&yr?new vr:void 0;for(u.set(t,e),u.set(e,t);++s<c;){var p=t[s],b=e[s];if(n)var y=i?n(b,p,s,e,t,u):n(p,b,s,t,e,u);if(void 0!==y){if(y)continue;d=!1;break}if(v){if(!pr(e,(function(t,e){if(i=e,!v.has(i)&&(p===t||o(p,t,r,n,u)))return v.push(e);var i}))){d=!1;break}}else if(p!==b&&!o(p,b,r,n,u)){d=!1;break}}return u.delete(t),u.delete(e),d}function jr(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function gr(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var _r=1,wr=2,mr="[object Boolean]",Or="[object Date]",Ar="[object Error]",Sr="[object Map]",kr="[object Number]",Pr="[object RegExp]",xr="[object Set]",zr="[object String]",Br="[object Symbol]",Ir="[object ArrayBuffer]",Er="[object DataView]",Mr=f?f.prototype:void 0,Fr=Mr?Mr.valueOf:void 0;var Dr=1,$r=Object.prototype.hasOwnProperty;var Nr=1,Ur="[object Arguments]",Cr="[object Array]",Gr="[object Object]",Tr=Object.prototype.hasOwnProperty;function Rr(t,e,r,o,u,i){var c=ct(t),a=ct(e),l=c?Cr:be(t),f=a?Cr:be(e),s=(l=l==Ur?Gr:l)==Gr,d=(f=f==Ur?Gr:f)==Gr,v=l==f;if(v&&st(t)){if(!st(e))return!1;c=!0,s=!1}if(v&&!s)return i||(i=new W),c||At(t)?hr(t,e,r,o,u,i):function(t,e,r,o,u,i,c){switch(r){case Er:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Ir:return!(t.byteLength!=e.byteLength||!i(new he(t),new he(e)));case mr:case Or:case kr:return n(+t,+e);case Ar:return t.name==e.name&&t.message==e.message;case Pr:case zr:return t==e+"";case Sr:var a=jr;case xr:var l=o&_r;if(a||(a=gr),t.size!=e.size&&!l)return!1;var f=c.get(t);if(f)return f==e;o|=wr,c.set(t,e);var s=hr(a(t),a(e),o,u,i,c);return c.delete(t),s;case Br:if(Fr)return Fr.call(t)==Fr.call(e)}return!1}(t,e,l,r,o,u,i);if(!(r&Nr)){var p=s&&Tr.call(t,"__wrapped__"),b=d&&Tr.call(e,"__wrapped__");if(p||b){var y=p?t.value():t,h=b?e.value():e;return i||(i=new W),u(y,h,r,o,i)}}return!!v&&(i||(i=new W),function(t,e,r,n,o,u){var i=r&Dr,c=Yt(t),a=c.length;if(a!=Yt(e).length&&!i)return!1;for(var l=a;l--;){var f=c[l];if(!(i?f in e:$r.call(e,f)))return!1}var s=u.get(t),d=u.get(e);if(s&&d)return s==e&&d==t;var v=!0;u.set(t,e),u.set(e,t);for(var p=i;++l<a;){var b=t[f=c[l]],y=e[f];if(n)var h=i?n(y,b,f,e,t,u):n(b,y,f,t,e,u);if(!(void 0===h?b===y||o(b,y,r,n,u):h)){v=!1;break}p||(p="constructor"==f)}if(v&&!p){var j=t.constructor,g=e.constructor;j==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof j&&j instanceof j&&"function"==typeof g&&g instanceof g||(v=!1)}return u.delete(t),u.delete(e),v}(t,e,r,o,u,i))}function qr(t,e,r,n,o){return t===e||(null==t||null==e||!tt(t)&&!tt(e)?t!=t&&e!=e:Rr(t,e,r,n,qr,o))}var Lr=1,Vr=2;function Wr(t){return t==t&&!_(t)}function Hr(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Jr(t){var e=function(t){for(var e=Ft(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,Wr(o)]}return e}(t);return 1==e.length&&e[0][2]?Hr(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,u=o,i=!n;if(null==t)return!u;for(t=Object(t);o--;){var c=r[o];if(i&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<u;){var a=(c=r[o])[0],l=t[a],f=c[1];if(i&&c[2]){if(void 0===l&&!(a in t))return!1}else{var s=new W;if(n)var d=n(l,f,a,t,e,s);if(!(void 0===d?qr(f,l,Lr|Vr,n,s):d))return!1}}return!0}(r,t,e)}}var Kr="[object Symbol]";function Qr(t){return"symbol"==typeof t||tt(t)&&g(t)==Kr}var Xr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yr=/^\w*$/;function Zr(t,e){if(ct(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!Qr(t))||(Yr.test(t)||!Xr.test(t)||null!=e&&t in Object(e))}var tn="Expected a function";function en(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(tn);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],u=r.cache;if(u.has(o))return u.get(o);var i=t.apply(this,n);return r.cache=u.set(o,i)||u,i};return r.cache=new(en.Cache||V),r}en.Cache=V;var rn,nn,on,un=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cn=/\\(\\)?/g,an=(rn=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(un,(function(t,r,n,o){e.push(n?o.replace(cn,"$1"):r||t)})),e},nn=en(rn,(function(t){return 500===on.size&&on.clear(),t})),on=nn.cache,nn),ln=an;function fn(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var sn=1/0,dn=f?f.prototype:void 0,vn=dn?dn.toString:void 0;function pn(t){if("string"==typeof t)return t;if(ct(t))return fn(t,pn)+"";if(Qr(t))return vn?vn.call(t):"";var e=t+"";return"0"==e&&1/t==-sn?"-0":e}function bn(t){return null==t?"":pn(t)}function yn(t,e){return ct(t)?t:Zr(t,e)?[t]:ln(bn(t))}var hn=1/0;function jn(t){if("string"==typeof t||Qr(t))return t;var e=t+"";return"0"==e&&1/t==-hn?"-0":e}function gn(t,e){for(var r=0,n=(e=yn(e,t)).length;null!=t&&r<n;)t=t[jn(e[r++])];return r&&r==n?t:void 0}function _n(t,e,r){var n=null==t?void 0:gn(t,e);return void 0===n?r:n}function wn(t,e){return null!=t&&e in Object(t)}function mn(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=yn(e,t)).length,u=!1;++n<o;){var i=jn(e[n]);if(!(u=null!=t&&r(t,i)))break;t=t[i]}return u||++n!=o?u:!!(o=null==t?0:t.length)&&yt(o)&&pt(i,o)&&(ct(t)||it(t))}(t,e,wn)}var On=1,An=2;function Sn(t){return t}function kn(t){return function(e){return null==e?void 0:e[t]}}function Pn(t){return Zr(t)?kn(jn(t)):function(t){return function(e){return gn(e,t)}}(t)}function xn(t){return"function"==typeof t?t:null==t?Sn:"object"==typeof t?ct(t)?(e=t[0],r=t[1],Zr(e)&&Wr(r)?Hr(jn(e),r):function(t){var n=_n(t,e);return void 0===n&&n===r?mn(t,e):qr(r,n,On|An)}):Jr(t):Pn(t);var e,r}function zn(t,e,r){var o=ct(t)?cr:dr;return r&&function(t,e,r){if(!_(r))return!1;var o=typeof e;return!!("number"==o?Mt(r)&&pt(e,r.length):"string"==o&&e in r)&&n(r[e],t)}(t,e,r)&&(e=void 0),o(t,xn(e))}function Bn(t,e){var r=-1,n=Mt(t)?Array(t.length):[];return sr(t,(function(t,o,u){n[++r]=e(t,o,u)})),n}function In(t,e){return(ct(t)?fn:Bn)(t,xn(e))}function En(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var u=Array(o);++n<o;)u[n]=t[n+e];return u}var Mn=Object.prototype.hasOwnProperty;function Fn(t,e){var r=-1,n=(e=yn(e,t)).length;if(!n)return!0;for(;++r<n;){var o=jn(e[r]);if("__proto__"===o&&!Mn.call(t,"__proto__"))return!1;if(("constructor"===o||"prototype"===o)&&r<n-1)return!1}var u=function(t,e){return e.length<2?t:gn(t,En(e,0,-1))}(t,e);return null==u||delete u[jn(function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}(e))]}var Dn="[object Object]",$n=Function.prototype,Nn=Object.prototype,Un=$n.toString,Cn=Nn.hasOwnProperty,Gn=Un.call(Object);function Tn(t){return function(t){if(!tt(t)||g(t)!=Dn)return!1;var e=Jt(t);if(null===e)return!0;var r=Cn.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Un.call(r)==Gn}(t)?void 0:t}var Rn=f?f.isConcatSpreadable:void 0;function qn(t){return ct(t)||it(t)||!!(Rn&&t&&t[Rn])}function Ln(t,e,r,n,o){var u=-1,i=t.length;for(r||(r=qn),o||(o=[]);++u<i;){var c=t[u];e>0&&r(c)?e>1?Ln(c,e-1,r,n,o):Ht(o,c):n||(o[o.length]=c)}return o}function Vn(t){return(null==t?0:t.length)?Ln(t,1):[]}var Wn=Math.max;var Hn=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:Sn,Jn=Hn,Kn=Date.now;var Qn=function(t){var e=0,r=0;return function(){var n=Kn(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Jn),Xn=Qn;var Yn=function(t){return Xn(function(t,e,r){return e=Wn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,u=Wn(n.length-e,0),i=Array(u);++o<u;)i[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(i),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}(t,void 0,Vn),t+"")}((function(t,e){var r={};if(null==t)return r;var n=!1;e=fn(e,(function(e){return e=yn(e,t),n||(n=e.length>1),e})),Z(t,Zt(t),r),n&&(r=nr(r,7,Tn));for(var o=e.length;o--;)Fn(r,e[o]);return r})),Zn=Yn,to="[object String]";var eo=kn("length"),ro=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var no="\\ud800-\\udfff",oo="["+no+"]",uo="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",io="\\ud83c[\\udffb-\\udfff]",co="[^"+no+"]",ao="(?:\\ud83c[\\udde6-\\uddff]){2}",lo="[\\ud800-\\udbff][\\udc00-\\udfff]",fo="(?:"+uo+"|"+io+")"+"?",so="[\\ufe0e\\ufe0f]?",vo=so+fo+("(?:\\u200d(?:"+[co,ao,lo].join("|")+")"+so+fo+")*"),po="(?:"+[co+uo+"?",uo,ao,lo,oo].join("|")+")",bo=RegExp(io+"(?="+io+")|"+po+vo,"g");function yo(t){return function(t){return ro.test(t)}(t)?function(t){for(var e=bo.lastIndex=0;bo.test(t);)++e;return e}(t):eo(t)}var ho="[object Map]",jo="[object Set]";function go(t){if(null==t)return 0;if(Mt(t))return"string"==typeof(e=t)||!ct(e)&&tt(e)&&g(e)==to?yo(t):t.length;var e,r=be(t);return r==ho||r==jo?t.size:Et(t).length}function _o(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}var wo=/\s/;var mo=/^\s+/;function Oo(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&wo.test(t.charAt(e)););return e}(t)+1).replace(mo,""):t}var Ao=NaN,So=/^[-+]0x[0-9a-f]+$/i,ko=/^0b[01]+$/i,Po=/^0o[0-7]+$/i,xo=parseInt;function zo(t){if("number"==typeof t)return t;if(Qr(t))return Ao;if(_(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=_(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Oo(t);var r=ko.test(t);return r||Po.test(t)?xo(t.slice(2),r?2:8):So.test(t)?Ao:+t}var Bo=1/0,Io=17976931348623157e292;function Eo(t){return t?(t=zo(t))===Bo||t===-Bo?(t<0?-1:1)*Io:t==t?t:0:0===t?t:0}function Mo(t){var e=Eo(t),r=e%1;return e==e?r?e-r:e:0}function Fo(t){return"[object String]"===Object.prototype.toString.call(t)}function Do(t){return!(!Fo(t)||""===t)}function $o(t){return t!=t}function No(t){let e=!1;if(Do(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if($o(t))return!1;e=!0}return e}function Uo(t){if(!No(t))return 0;return Eo(t)}function Co(t){return!!No(t)&&(t=Uo(t),"number"==typeof(e=t)&&e==Mo(e));var e}var Go=l.isFinite,To=Math.min;var Ro=function(t){var e=Math[t];return function(t,r){if(t=zo(t),(r=null==r?0:To(Mo(r),292))&&Go(t)){var n=(bn(t)+"e").split("e");return+((n=(bn(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),qo=Ro;function Lo(t){if(!No(t))return 0;t=Uo(t);let e=qo(t);return"0"===String(e)?0:e}let Vo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Wo=Vo.length;function Ho(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];var r;t=Co(r=t)&&Lo(r)>0?Lo(t):32;for(let r=0;r<t;r++)e[r]=Vo[0|Math.random()*Wo];return e.join("")}var Jo="[object Boolean]";function Ko(t){return!0===(e=t)||!1===e||tt(e)&&g(e)==Jo;var e}function Qo(t){return"[object Array]"===Object.prototype.toString.call(t)}function Xo(t){return"[object Object]"===Object.prototype.toString.call(t)}function Yo(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(Xo(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!Fo(t)||""!==t)}(t)||(!!function(t){return!!Qo(t)&&0===t.length}(t)||!!$o(t)))))}function Zo(t){return!!Qo(t)&&(0!==t.length&&(1!==t.length||!Yo(t[0])))}function tu(t){if(Xo(t)){for(let e in t)return!0;return!1}return!1}function eu(t,e){var r;return(ct(t)?H:sr)(t,"function"==typeof(r=e)?r:Sn)}function ru(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function nu(t,e){let r=_o();if(!Qo(t)&&!Xo(t))return r.reject("rs is not an array or object"),r;let n=!1;if(Xo(t)){n=!0;let e=[];eu(t,((t,r)=>{e.push({k:r,v:t})})),t=e}ru(e)||(e=function(t){return t});let o=-1,u=[];return t.reduce((function(t,r){return t.then((function(t){u.push(t),o+=1;let i=o,c=r;return n&&(i=r.k,c=r.v),ru(e)?e(c,i):c}))}),Promise.resolve()).then((function(t){var e,n,o,i;u.push(t),i=null==(e=u)?0:e.length,u=i?En(e,(n=o||void 0===n?1:Mo(n))<0?0:n,i):[],r.resolve(u)})).catch((function(t){r.reject(t)})),r}return function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n.url||(n.url="mongodb://127.0.0.1:27017"),n.db||(n.db="worm"),n.cl||(n.cl="test");let o=_n(n,"autoGenPk");Ko(o)||(o=!0);let u=!1,i=!1,c=new t.EventEmitter,a=e.MongoClient;function l(t){let e=_n(t,"message");return Do(e)?e:String(t)}function f(t,e,r){try{c.emit("change",t,e,r)}catch(t){console.log(t)}}function s(t,e){if(!Do(t.id)){if(!o)throw new Error(`invalid data[${e}].id, autoGenPk is false`);t.id=Ho()}return t}function d(t){let e=_n(t,"writeErrors");return Zo(e)?zn(e,(function(t){return 11e3===_n(t,"code")||11e3===_n(t,"err.code")})):11e3===_n(t,"code")}async function v(t){u||(await t.createIndex({id:1},{unique:!0}),u=!0)}async function p(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0,r=!1,n=null;try{let r=e.find(t);n=await r.toArray()}catch(t){r=!0,n=t}return r?Promise.reject(n):n}return c.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=new a(n.url),o=null;try{let e=r.db(n.db).collection(n.cl).find(t);o=await e.toArray(),o=In(o,(function(t){return t=Zn(t,"_id")}))}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e?Promise.reject(o):o},c.selectByPk=async function(t){let e=!1;if(!Do(t))return null;let r=new a(n.url),o=null;try{let e=r.db(n.db).collection(n.cl),u=await e.findOne({id:t},{projection:{_id:0}});o=tu(u)?u:null}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e?Promise.reject(o):o},c.insert=async function(t){let e=!1;if(!tu(t)&&!Zo(t))return{n:0,nInserted:0,ok:1};t=ir(t);let r=new a(n.url),o=null;try{await r.connect();let e=r.db(n.db).collection(n.cl);Qo(t)||(t=[t]),t=In(t,s),await v(e);let u=go(t),i=0;try{i=(await e.insertMany(t,{ordered:!1})).insertedCount}catch(t){if(!d(t))throw t;i=_n(t,"result.insertedCount",0)}o={n:u,nInserted:i,ok:1}}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e||f("insert",t,o),e?Promise.reject(o):o},c.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!1;if(!tu(t)&&!Zo(t))return[];t=ir(t);let o=_n(e,"autoInsert",!0),u=new a(n.url),i=null;try{await u.connect();let e=u.db(n.db).collection(n.cl);Qo(t)||(t=[t]),t=In(t,s),await v(e),i=await nu(t,(async t=>async function(t,e,r){let n=null,o=!1;for(let u=0;u<3;u++)try{let u=await t.updateOne({id:e.id},{$set:e},{upsert:r}),i=_n(u,"matchedCount",0),c=_n(u,"modifiedCount",0);_n(u,"upsertedCount",0)>0?(n={n:1,nInserted:1,nModified:0,ok:1},o=!0):n=i>0?{n:1,nInserted:0,nModified:c>0?1:0,ok:1}:{n:0,nInserted:0,nModified:0,ok:1};break}catch(t){if(d(t)&&u<2)continue;n={n:1,nInserted:0,nModified:0,ok:0,err:l(t)};break}return o&&f("insert",[e],n),n}(e,t,o)))}catch(t){r=!0,i=t}finally{await u.close(),u=null}return r||f("save",t,i),r?Promise.reject(i):i},c.del=async function(t){let e=!1;if(!tu(t)&&!Zo(t))return[];t=ir(t);let r=new a(n.url),o=null;try{await r.connect();let e=r.db(n.db).collection(n.cl);Qo(t)||(t=[t]),o=await nu(t,(async t=>{let r=_n(t,"id");if(!Do(r))return{n:0,nDeleted:0,ok:0,err:`invalid id[${r}]`};let n=null;try{let t=_n(await e.deleteOne({id:r}),"deletedCount",0);n={n:t,nDeleted:t,ok:1}}catch(t){n={n:1,nDeleted:0,ok:0,err:l(t)}}return n}))}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e||f("del",t,o),e?Promise.reject(o):o},c.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=new a(n.url),o=null;try{let e=r.db(n.db).collection(n.cl),u=_n(await e.deleteMany(t),"deletedCount",0);o={n:u,nDeleted:u,ok:1}}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e||f("delAll",null,o),e?Promise.reject(o):o},c.selectByPkGfs=async function(t){let r=!1;if(!Do(t))return null;let o=new a(n.url),u=null;try{u={id:t,u8a:await(async t=>{let r=_o(),u=o.db(n.db),i=new e.GridFSBucket(u,{chunkSizeBytes:10485760,bucketName:n.cl}),c=Buffer.from(""),a=i.openDownloadStreamByName(t);return a.on("data",(function(t){c=Buffer.concat([c,t])})),a.on("error",(function(t){r.reject(t)})),a.on("end",(function(){let t=new Uint8Array(c);c=null,r.resolve(t)})),r})(t)}}catch(t){"ENOENT"===_n(t,"code")?u=null:(r=!0,u=t)}finally{await o.close(),o=null}return r?Promise.reject(u):u},c.insertGfs=async function(t){let o=!1;if(!tu(t)&&!Zo(t))return{n:0,nInserted:0,ok:1};let u=new a(n.url),c=null;try{await u.connect();let o=u.db(n.db),a=new e.GridFSBucket(o,{chunkSizeBytes:10485760,bucketName:n.cl}),l=o.collection(`${n.cl}.chunks`);Qo(t)||(t=[t]),t=In(t,(function(t,e){if(!function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}((t=s(t={...t},e)).u8a))throw new Error(`invalid data[${e}].u8a`);return t})),await async function(t){i||(await t.collection(`${n.cl}.files`).createIndex({filename:1},{unique:!0}),i=!0)}(o);let f=go(t),v=0;await nu(t,(async t=>{let e=await function(t,e,n,o){let u=_o(),i=t.openUploadStream(n),c=i.id,a=new r.Readable;return a._read=()=>{},a.push(Buffer.from(o)),a.push(null),a.pipe(i).on("error",(function(t){d(t)?e.deleteMany({files_id:c}).then((function(){u.resolve(!1)})).catch((function(t){u.reject(t)})):u.reject(t)})).on("finish",(function(){u.resolve(!0)})),u}(a,l,t.id,t.u8a);e&&v++})),c={n:f,nInserted:v,ok:1}}catch(t){o=!0,c=t}finally{await u.close(),u=null}return o||f("insertGfs",t,c),o?Promise.reject(c):c},c.delGfs=async function(t){let r=!1;if(!tu(t)&&!Zo(t))return[];let o=new a(n.url),u=null;try{await o.connect();let r=o.db(n.db),i=new e.GridFSBucket(r,{chunkSizeBytes:10485760,bucketName:n.cl});Qo(t)||(t=[t]),u=await nu(t,(async t=>{let e=_n(t,"id");if(!Do(e))return{n:0,nDeleted:0,ok:0,err:`invalid id[${e}]`};let r=null;try{let t=await p({filename:e},i),n=0;for(let e of t)await i.delete(e._id),n++;r={n:n>0?1:0,nDeleted:n,ok:1}}catch(t){r={n:1,nDeleted:0,ok:0,err:l(t)}}return r}))}catch(t){r=!0,u=t}finally{await o.close(),o=null}return r||f("delGfs",t,u),r?Promise.reject(u):u},c.delAllGfs=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=!1,o=new a(n.url),u=null;try{let r=o.db(n.db),i=new e.GridFSBucket(r,{chunkSizeBytes:10485760,bucketName:n.cl}),c=await p(t,i),a=In(c,(function(t){return async function(t,e){await e.delete(t)}(t._id,i)}));await Promise.all(a);let l=go(c);u={n:l,nDeleted:l,ok:1}}catch(t){r=!0,u=t}finally{await o.close(),o=null}return r||f("delAllGfs",null,u),r?Promise.reject(u):u},c}}));
6
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("mongodb"),require("stream")):"function"==typeof define&&define.amd?define(["mongodb","stream"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-mongodb"]=e(t.mongodb,t.stream)}(this,(function(t,e){"use strict";function n(t,e){return t===e||t!=t&&e!=e}function r(t,e){for(var r=t.length;r--;)if(n(t[r][0],e))return r;return-1}var o=Array.prototype.splice;function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}u.prototype.clear=function(){this.__data__=[],this.size=0},u.prototype.delete=function(t){var e=this.__data__,n=r(e,t);return!(n<0)&&(n==e.length-1?e.pop():o.call(e,n,1),--this.size,!0)},u.prototype.get=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]},u.prototype.has=function(t){return r(this.__data__,t)>-1},u.prototype.set=function(t,e){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this};var i="object"==typeof global&&global&&global.Object===Object&&global,c="object"==typeof self&&self&&self.Object===Object&&self,a=i||c||Function("return this")(),l=a.Symbol,f=Object.prototype,s=f.hasOwnProperty,v=f.toString,p=l?l.toStringTag:void 0;var d=Object.prototype.toString;var y="[object Null]",b="[object Undefined]",h=l?l.toStringTag:void 0;function j(t){return null==t?void 0===t?b:y:h&&h in Object(t)?function(t){var e=s.call(t,p),n=t[p];try{t[p]=void 0;var r=!0}catch(t){}var o=v.call(t);return r&&(e?t[p]=n:delete t[p]),o}(t):function(t){return d.call(t)}(t)}function g(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var _="[object AsyncFunction]",w="[object Function]",m="[object GeneratorFunction]",O="[object Proxy]";function A(t){if(!g(t))return!1;var e=j(t);return e==w||e==m||e==_||e==O}var k,x=a["__core-js_shared__"],S=(k=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"";var P=Function.prototype.toString;function z(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var B=/^\[object .+?Constructor\]$/,E=Function.prototype,I=Object.prototype,M=E.toString,F=I.hasOwnProperty,C=RegExp("^"+M.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function D(t){return!(!g(t)||(e=t,S&&S in e))&&(A(t)?C:B).test(z(t));var e}function G(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return D(n)?n:void 0}var N=G(a,"Map"),$=G(Object,"create");var U=Object.prototype.hasOwnProperty;var T=Object.prototype.hasOwnProperty;function L(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function q(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}L.prototype.clear=function(){this.__data__=$?$(null):{},this.size=0},L.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},L.prototype.get=function(t){var e=this.__data__;if($){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return U.call(e,t)?e[t]:void 0},L.prototype.has=function(t){var e=this.__data__;return $?void 0!==e[t]:T.call(e,t)},L.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=$&&void 0===e?"__lodash_hash_undefined__":e,this},q.prototype.clear=function(){this.size=0,this.__data__={hash:new L,map:new(N||u),string:new L}},q.prototype.delete=function(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e},q.prototype.get=function(t){return R(this,t).get(t)},q.prototype.has=function(t){return R(this,t).has(t)},q.prototype.set=function(t,e){var n=R(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function V(t){var e=this.__data__=new u(t);this.size=e.size}function W(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}V.prototype.clear=function(){this.__data__=new u,this.size=0},V.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},V.prototype.get=function(t){return this.__data__.get(t)},V.prototype.has=function(t){return this.__data__.has(t)},V.prototype.set=function(t,e){var n=this.__data__;if(n instanceof u){var r=n.__data__;if(!N||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new q(r)}return n.set(t,e),this.size=n.size,this};var H=function(){try{var t=G(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),J=H;function K(t,e,n){"__proto__"==e&&J?J(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Q=Object.prototype.hasOwnProperty;function X(t,e,r){var o=t[e];Q.call(t,e)&&n(o,r)&&(void 0!==r||e in t)||K(t,e,r)}function Y(t,e,n,r){var o=!n;n||(n={});for(var u=-1,i=e.length;++u<i;){var c=e[u],a=r?r(n[c],t[c],c,n,t):void 0;void 0===a&&(a=t[c]),o?K(n,c,a):X(n,c,a)}return n}function Z(t){return null!=t&&"object"==typeof t}function tt(t){return Z(t)&&"[object Arguments]"==j(t)}var et=Object.prototype,nt=et.hasOwnProperty,rt=et.propertyIsEnumerable,ot=tt(function(){return arguments}())?tt:function(t){return Z(t)&&nt.call(t,"callee")&&!rt.call(t,"callee")},ut=ot,it=Array.isArray;var ct="object"==typeof exports&&exports&&!exports.nodeType&&exports,at=ct&&"object"==typeof module&&module&&!module.nodeType&&module,lt=at&&at.exports===ct?a.Buffer:void 0,ft=(lt?lt.isBuffer:void 0)||function(){return!1},st=9007199254740991,vt=/^(?:0|[1-9]\d*)$/;function pt(t,e){var n=typeof t;return!!(e=null==e?st:e)&&("number"==n||"symbol"!=n&&vt.test(t))&&t>-1&&t%1==0&&t<e}var dt=9007199254740991;function yt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=dt}var bt={};function ht(t){return function(e){return t(e)}}bt["[object Float32Array]"]=bt["[object Float64Array]"]=bt["[object Int8Array]"]=bt["[object Int16Array]"]=bt["[object Int32Array]"]=bt["[object Uint8Array]"]=bt["[object Uint8ClampedArray]"]=bt["[object Uint16Array]"]=bt["[object Uint32Array]"]=!0,bt["[object Arguments]"]=bt["[object Array]"]=bt["[object ArrayBuffer]"]=bt["[object Boolean]"]=bt["[object DataView]"]=bt["[object Date]"]=bt["[object Error]"]=bt["[object Function]"]=bt["[object Map]"]=bt["[object Number]"]=bt["[object Object]"]=bt["[object RegExp]"]=bt["[object Set]"]=bt["[object String]"]=bt["[object WeakMap]"]=!1;var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,gt=jt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=gt&&gt.exports===jt&&i.process,wt=function(){try{var t=gt&&gt.require&&gt.require("util").types;return t||_t&&_t.binding&&_t.binding("util")}catch(t){}}(),mt=wt&&wt.isTypedArray,Ot=mt?ht(mt):function(t){return Z(t)&&yt(t.length)&&!!bt[j(t)]},At=Object.prototype.hasOwnProperty;function kt(t,e){var n=it(t),r=!n&&ut(t),o=!n&&!r&&ft(t),u=!n&&!r&&!o&&Ot(t),i=n||r||o||u,c=i?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],a=c.length;for(var l in t)!e&&!At.call(t,l)||i&&("length"==l||o&&("offset"==l||"parent"==l)||u&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||pt(l,a))||c.push(l);return c}var xt=Object.prototype;function St(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||xt)}function Pt(t,e){return function(n){return t(e(n))}}var zt=Pt(Object.keys,Object),Bt=Object.prototype.hasOwnProperty;function Et(t){if(!St(t))return zt(t);var e=[];for(var n in Object(t))Bt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function It(t){return null!=t&&yt(t.length)&&!A(t)}function Mt(t){return It(t)?kt(t):Et(t)}var Ft=Object.prototype.hasOwnProperty;function Ct(t){if(!g(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=St(t),n=[];for(var r in t)("constructor"!=r||!e&&Ft.call(t,r))&&n.push(r);return n}function Dt(t){return It(t)?kt(t,!0):Ct(t)}var Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,$t=Nt&&Nt.exports===Gt?a.Buffer:void 0,Ut=$t?$t.allocUnsafe:void 0;function Tt(){return[]}var Lt=Object.prototype.propertyIsEnumerable,Rt=Object.getOwnPropertySymbols,qt=Rt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,u=[];++n<r;){var i=t[n];e(i,n,t)&&(u[o++]=i)}return u}(Rt(t),(function(e){return Lt.call(t,e)})))}:Tt,Vt=qt;function Wt(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}var Ht=Pt(Object.getPrototypeOf,Object),Jt=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Wt(e,Vt(t)),t=Ht(t);return e}:Tt,Kt=Jt;function Qt(t,e,n){var r=e(t);return it(t)?r:Wt(r,n(t))}function Xt(t){return Qt(t,Mt,Vt)}function Yt(t){return Qt(t,Dt,Kt)}var Zt=G(a,"DataView"),te=G(a,"Promise"),ee=G(a,"Set"),ne=G(a,"WeakMap"),re="[object Map]",oe="[object Promise]",ue="[object Set]",ie="[object WeakMap]",ce="[object DataView]",ae=z(Zt),le=z(N),fe=z(te),se=z(ee),ve=z(ne),pe=j;(Zt&&pe(new Zt(new ArrayBuffer(1)))!=ce||N&&pe(new N)!=re||te&&pe(te.resolve())!=oe||ee&&pe(new ee)!=ue||ne&&pe(new ne)!=ie)&&(pe=function(t){var e=j(t),n="[object Object]"==e?t.constructor:void 0,r=n?z(n):"";if(r)switch(r){case ae:return ce;case le:return re;case fe:return oe;case se:return ue;case ve:return ie}return e});var de=pe,ye=Object.prototype.hasOwnProperty;var be=a.Uint8Array;function he(t){var e=new t.constructor(t.byteLength);return new be(e).set(new be(t)),e}var je=/\w*$/;var ge=l?l.prototype:void 0,_e=ge?ge.valueOf:void 0;var we="[object Boolean]",me="[object Date]",Oe="[object Map]",Ae="[object Number]",ke="[object RegExp]",xe="[object Set]",Se="[object String]",Pe="[object Symbol]",ze="[object ArrayBuffer]",Be="[object DataView]",Ee="[object Float32Array]",Ie="[object Float64Array]",Me="[object Int8Array]",Fe="[object Int16Array]",Ce="[object Int32Array]",De="[object Uint8Array]",Ge="[object Uint8ClampedArray]",Ne="[object Uint16Array]",$e="[object Uint32Array]";function Ue(t,e,n){var r,o,u,i=t.constructor;switch(e){case ze:return he(t);case we:case me:return new i(+t);case Be:return function(t,e){var n=e?he(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case Ee:case Ie:case Me:case Fe:case Ce:case De:case Ge:case Ne:case $e:return function(t,e){var n=e?he(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,n);case Oe:return new i;case Ae:case Se:return new i(t);case ke:return(u=new(o=t).constructor(o.source,je.exec(o))).lastIndex=o.lastIndex,u;case xe:return new i;case Pe:return r=t,_e?Object(_e.call(r)):{}}}var Te=Object.create,Le=function(){function t(){}return function(e){if(!g(e))return{};if(Te)return Te(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}(),Re=Le;var qe=wt&&wt.isMap,Ve=qe?ht(qe):function(t){return Z(t)&&"[object Map]"==de(t)};var We=wt&&wt.isSet,He=We?ht(We):function(t){return Z(t)&&"[object Set]"==de(t)},Je=1,Ke=2,Qe=4,Xe="[object Arguments]",Ye="[object Function]",Ze="[object GeneratorFunction]",tn="[object Object]",en={};function nn(t,e,n,r,o,u){var i,c=e&Je,a=e&Ke,l=e&Qe;if(n&&(i=o?n(t,r,o,u):n(t)),void 0!==i)return i;if(!g(t))return t;var f=it(t);if(f){if(i=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&ye.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!c)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,i)}else{var s=de(t),v=s==Ye||s==Ze;if(ft(t))return function(t,e){if(e)return t.slice();var n=t.length,r=Ut?Ut(n):new t.constructor(n);return t.copy(r),r}(t,c);if(s==tn||s==Xe||v&&!o){if(i=a||v?{}:function(t){return"function"!=typeof t.constructor||St(t)?{}:Re(Ht(t))}(t),!c)return a?function(t,e){return Y(t,Kt(t),e)}(t,function(t,e){return t&&Y(e,Dt(e),t)}(i,t)):function(t,e){return Y(t,Vt(t),e)}(t,function(t,e){return t&&Y(e,Mt(e),t)}(i,t))}else{if(!en[s])return o?t:{};i=Ue(t,s,c)}}u||(u=new V);var p=u.get(t);if(p)return p;u.set(t,i),He(t)?t.forEach((function(r){i.add(nn(r,e,n,r,t,u))})):Ve(t)&&t.forEach((function(r,o){i.set(o,nn(r,e,n,o,t,u))}));var d=f?void 0:(l?a?Yt:Xt:a?Dt:Mt)(t);return W(d||t,(function(r,o){d&&(r=t[o=r]),X(i,o,nn(r,e,n,o,t,u))})),i}en[Xe]=en["[object Array]"]=en["[object ArrayBuffer]"]=en["[object DataView]"]=en["[object Boolean]"]=en["[object Date]"]=en["[object Float32Array]"]=en["[object Float64Array]"]=en["[object Int8Array]"]=en["[object Int16Array]"]=en["[object Int32Array]"]=en["[object Map]"]=en["[object Number]"]=en[tn]=en["[object RegExp]"]=en["[object Set]"]=en["[object String]"]=en["[object Symbol]"]=en["[object Uint8Array]"]=en["[object Uint8ClampedArray]"]=en["[object Uint16Array]"]=en["[object Uint32Array]"]=!0,en["[object Error]"]=en[Ye]=en["[object WeakMap]"]=!1;var rn=1,on=4;function un(t){return nn(t,rn|on)}function cn(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}var an,ln=function(t,e,n){for(var r=-1,o=Object(t),u=n(t),i=u.length;i--;){var c=u[an?i:++r];if(!1===e(o[c],c,o))break}return t};var fn=function(t,e){return function(n,r){if(null==n)return n;if(!It(n))return t(n,r);for(var o=n.length,u=e?o:-1,i=Object(n);(e?u--:++u<o)&&!1!==r(i[u],u,i););return n}}((function(t,e){return t&&ln(t,e,Mt)})),sn=fn;function vn(t,e){var n=!0;return sn(t,(function(t,r,o){return n=!!e(t,r,o)})),n}function pn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new q;++e<n;)this.add(t[e])}function dn(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}pn.prototype.add=pn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},pn.prototype.has=function(t){return this.__data__.has(t)};var yn=1,bn=2;function hn(t,e,n,r,o,u){var i=n&yn,c=t.length,a=e.length;if(c!=a&&!(i&&a>c))return!1;var l=u.get(t),f=u.get(e);if(l&&f)return l==e&&f==t;var s=-1,v=!0,p=n&bn?new pn:void 0;for(u.set(t,e),u.set(e,t);++s<c;){var d=t[s],y=e[s];if(r)var b=i?r(y,d,s,e,t,u):r(d,y,s,t,e,u);if(void 0!==b){if(b)continue;v=!1;break}if(p){if(!dn(e,(function(t,e){if(i=e,!p.has(i)&&(d===t||o(d,t,n,r,u)))return p.push(e);var i}))){v=!1;break}}else if(d!==y&&!o(d,y,n,r,u)){v=!1;break}}return u.delete(t),u.delete(e),v}function jn(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function gn(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var _n=1,wn=2,mn="[object Boolean]",On="[object Date]",An="[object Error]",kn="[object Map]",xn="[object Number]",Sn="[object RegExp]",Pn="[object Set]",zn="[object String]",Bn="[object Symbol]",En="[object ArrayBuffer]",In="[object DataView]",Mn=l?l.prototype:void 0,Fn=Mn?Mn.valueOf:void 0;var Cn=1,Dn=Object.prototype.hasOwnProperty;var Gn=1,Nn="[object Arguments]",$n="[object Array]",Un="[object Object]",Tn=Object.prototype.hasOwnProperty;function Ln(t,e,r,o,u,i){var c=it(t),a=it(e),l=c?$n:de(t),f=a?$n:de(e),s=(l=l==Nn?Un:l)==Un,v=(f=f==Nn?Un:f)==Un,p=l==f;if(p&&ft(t)){if(!ft(e))return!1;c=!0,s=!1}if(p&&!s)return i||(i=new V),c||Ot(t)?hn(t,e,r,o,u,i):function(t,e,r,o,u,i,c){switch(r){case In:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case En:return!(t.byteLength!=e.byteLength||!i(new be(t),new be(e)));case mn:case On:case xn:return n(+t,+e);case An:return t.name==e.name&&t.message==e.message;case Sn:case zn:return t==e+"";case kn:var a=jn;case Pn:var l=o&_n;if(a||(a=gn),t.size!=e.size&&!l)return!1;var f=c.get(t);if(f)return f==e;o|=wn,c.set(t,e);var s=hn(a(t),a(e),o,u,i,c);return c.delete(t),s;case Bn:if(Fn)return Fn.call(t)==Fn.call(e)}return!1}(t,e,l,r,o,u,i);if(!(r&Gn)){var d=s&&Tn.call(t,"__wrapped__"),y=v&&Tn.call(e,"__wrapped__");if(d||y){var b=d?t.value():t,h=y?e.value():e;return i||(i=new V),u(b,h,r,o,i)}}return!!p&&(i||(i=new V),function(t,e,n,r,o,u){var i=n&Cn,c=Xt(t),a=c.length;if(a!=Xt(e).length&&!i)return!1;for(var l=a;l--;){var f=c[l];if(!(i?f in e:Dn.call(e,f)))return!1}var s=u.get(t),v=u.get(e);if(s&&v)return s==e&&v==t;var p=!0;u.set(t,e),u.set(e,t);for(var d=i;++l<a;){var y=t[f=c[l]],b=e[f];if(r)var h=i?r(b,y,f,e,t,u):r(y,b,f,t,e,u);if(!(void 0===h?y===b||o(y,b,n,r,u):h)){p=!1;break}d||(d="constructor"==f)}if(p&&!d){var j=t.constructor,g=e.constructor;j==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof j&&j instanceof j&&"function"==typeof g&&g instanceof g||(p=!1)}return u.delete(t),u.delete(e),p}(t,e,r,o,u,i))}function Rn(t,e,n,r,o){return t===e||(null==t||null==e||!Z(t)&&!Z(e)?t!=t&&e!=e:Ln(t,e,n,r,Rn,o))}var qn=1,Vn=2;function Wn(t){return t==t&&!g(t)}function Hn(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}function Jn(t){var e=function(t){for(var e=Mt(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,Wn(o)]}return e}(t);return 1==e.length&&e[0][2]?Hn(e[0][0],e[0][1]):function(n){return n===t||function(t,e,n,r){var o=n.length,u=o,i=!r;if(null==t)return!u;for(t=Object(t);o--;){var c=n[o];if(i&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<u;){var a=(c=n[o])[0],l=t[a],f=c[1];if(i&&c[2]){if(void 0===l&&!(a in t))return!1}else{var s=new V;if(r)var v=r(l,f,a,t,e,s);if(!(void 0===v?Rn(f,l,qn|Vn,r,s):v))return!1}}return!0}(n,t,e)}}var Kn="[object Symbol]";function Qn(t){return"symbol"==typeof t||Z(t)&&j(t)==Kn}var Xn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yn=/^\w*$/;function Zn(t,e){if(it(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!Qn(t))||(Yn.test(t)||!Xn.test(t)||null!=e&&t in Object(e))}var tr="Expected a function";function er(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(tr);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],u=n.cache;if(u.has(o))return u.get(o);var i=t.apply(this,r);return n.cache=u.set(o,i)||u,i};return n.cache=new(er.Cache||q),n}er.Cache=q;var nr,rr,or,ur=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,cr=(nr=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ur,(function(t,n,r,o){e.push(r?o.replace(ir,"$1"):n||t)})),e},rr=er(nr,(function(t){return 500===or.size&&or.clear(),t})),or=rr.cache,rr),ar=cr;function lr(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}var fr=1/0,sr=l?l.prototype:void 0,vr=sr?sr.toString:void 0;function pr(t){if("string"==typeof t)return t;if(it(t))return lr(t,pr)+"";if(Qn(t))return vr?vr.call(t):"";var e=t+"";return"0"==e&&1/t==-fr?"-0":e}function dr(t){return null==t?"":pr(t)}function yr(t,e){return it(t)?t:Zn(t,e)?[t]:ar(dr(t))}var br=1/0;function hr(t){if("string"==typeof t||Qn(t))return t;var e=t+"";return"0"==e&&1/t==-br?"-0":e}function jr(t,e){for(var n=0,r=(e=yr(e,t)).length;null!=t&&n<r;)t=t[hr(e[n++])];return n&&n==r?t:void 0}function gr(t,e,n){var r=null==t?void 0:jr(t,e);return void 0===r?n:r}function _r(t,e){return null!=t&&e in Object(t)}function wr(t,e){return null!=t&&function(t,e,n){for(var r=-1,o=(e=yr(e,t)).length,u=!1;++r<o;){var i=hr(e[r]);if(!(u=null!=t&&n(t,i)))break;t=t[i]}return u||++r!=o?u:!!(o=null==t?0:t.length)&&yt(o)&&pt(i,o)&&(it(t)||ut(t))}(t,e,_r)}var mr=1,Or=2;function Ar(t){return t}function kr(t){return function(e){return null==e?void 0:e[t]}}function xr(t){return Zn(t)?kr(hr(t)):function(t){return function(e){return jr(e,t)}}(t)}function Sr(t){return"function"==typeof t?t:null==t?Ar:"object"==typeof t?it(t)?(e=t[0],n=t[1],Zn(e)&&Wn(n)?Hn(hr(e),n):function(t){var r=gr(t,e);return void 0===r&&r===n?wr(t,e):Rn(n,r,mr|Or)}):Jn(t):xr(t);var e,n}function Pr(t,e,r){var o=it(t)?cn:vn;return r&&function(t,e,r){if(!g(r))return!1;var o=typeof e;return!!("number"==o?It(r)&&pt(e,r.length):"string"==o&&e in r)&&n(r[e],t)}(t,e,r)&&(e=void 0),o(t,Sr(e))}function zr(t,e){var n=-1,r=It(t)?Array(t.length):[];return sn(t,(function(t,o,u){r[++n]=e(t,o,u)})),r}function Br(t,e){return(it(t)?lr:zr)(t,Sr(e))}function Er(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var u=Array(o);++r<o;)u[r]=t[r+e];return u}var Ir=Object.prototype.hasOwnProperty;function Mr(t,e){var n=-1,r=(e=yr(e,t)).length;if(!r)return!0;for(;++n<r;){var o=hr(e[n]);if("__proto__"===o&&!Ir.call(t,"__proto__"))return!1;if(("constructor"===o||"prototype"===o)&&n<r-1)return!1}var u=function(t,e){return e.length<2?t:jr(t,Er(e,0,-1))}(t,e);return null==u||delete u[hr(function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}(e))]}var Fr="[object Object]",Cr=Function.prototype,Dr=Object.prototype,Gr=Cr.toString,Nr=Dr.hasOwnProperty,$r=Gr.call(Object);function Ur(t){return function(t){if(!Z(t)||j(t)!=Fr)return!1;var e=Ht(t);if(null===e)return!0;var n=Nr.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Gr.call(n)==$r}(t)?void 0:t}var Tr=l?l.isConcatSpreadable:void 0;function Lr(t){return it(t)||ut(t)||!!(Tr&&t&&t[Tr])}function Rr(t,e,n,r,o){var u=-1,i=t.length;for(n||(n=Lr),o||(o=[]);++u<i;){var c=t[u];e>0&&n(c)?e>1?Rr(c,e-1,n,r,o):Wt(o,c):r||(o[o.length]=c)}return o}function qr(t){return(null==t?0:t.length)?Rr(t,1):[]}var Vr=Math.max;var Wr=J?function(t,e){return J(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Ar,Hr=Wr,Jr=Date.now;var Kr=function(t){var e=0,n=0;return function(){var r=Jr(),o=16-(r-n);if(n=r,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Hr),Qr=Kr;var Xr=function(t){return Qr(function(t,e,n){return e=Vr(void 0===e?t.length-1:e,0),function(){for(var r=arguments,o=-1,u=Vr(r.length-e,0),i=Array(u);++o<u;)i[o]=r[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=r[o];return c[e]=n(i),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,c)}}(t,void 0,qr),t+"")}((function(t,e){var n={};if(null==t)return n;var r=!1;e=lr(e,(function(e){return e=yr(e,t),r||(r=e.length>1),e})),Y(t,Yt(t),n),r&&(n=nn(n,7,Ur));for(var o=e.length;o--;)Mr(n,e[o]);return n})),Yr=Xr,Zr="[object String]";var to=kr("length"),eo=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var no="\\ud800-\\udfff",ro="["+no+"]",oo="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",uo="\\ud83c[\\udffb-\\udfff]",io="[^"+no+"]",co="(?:\\ud83c[\\udde6-\\uddff]){2}",ao="[\\ud800-\\udbff][\\udc00-\\udfff]",lo="(?:"+oo+"|"+uo+")"+"?",fo="[\\ufe0e\\ufe0f]?",so=fo+lo+("(?:\\u200d(?:"+[io,co,ao].join("|")+")"+fo+lo+")*"),vo="(?:"+[io+oo+"?",oo,co,ao,ro].join("|")+")",po=RegExp(uo+"(?="+uo+")|"+vo+so,"g");function yo(t){return function(t){return eo.test(t)}(t)?function(t){for(var e=po.lastIndex=0;po.test(t);)++e;return e}(t):to(t)}var bo="[object Map]",ho="[object Set]";function jo(t){if(null==t)return 0;if(It(t))return"string"==typeof(e=t)||!it(e)&&Z(e)&&j(e)==Zr?yo(t):t.length;var e,n=de(t);return n==bo||n==ho?t.size:Et(t).length}var go={};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function u(t,e,r,u,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,u||t,i),a=n?n+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],c]:t._events[a].push(c):(t._events[a]=c,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,r,o=[];if(0===this._eventsCount)return o;for(r in t=this._events)e.call(t,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},c.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,u=r.length,i=new Array(u);o<u;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},c.prototype.emit=function(t,e,r,o,u,i){var c=n?n+t:t;if(!this._events[c])return!1;var a,l,f=this._events[c],s=arguments.length;if(f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),s){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,r),!0;case 4:return f.fn.call(f.context,e,r,o),!0;case 5:return f.fn.call(f.context,e,r,o,u),!0;case 6:return f.fn.call(f.context,e,r,o,u,i),!0}for(l=1,a=new Array(s-1);l<s;l++)a[l-1]=arguments[l];f.fn.apply(f.context,a)}else{var v,p=f.length;for(l=0;l<p;l++)switch(f[l].once&&this.removeListener(t,f[l].fn,void 0,!0),s){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,e);break;case 3:f[l].fn.call(f[l].context,e,r);break;case 4:f[l].fn.call(f[l].context,e,r,o);break;default:if(!a)for(v=1,a=new Array(s-1);v<s;v++)a[v-1]=arguments[v];f[l].fn.apply(f[l].context,a)}}return!0},c.prototype.on=function(t,e,n){return u(this,t,e,n,!1)},c.prototype.once=function(t,e,n){return u(this,t,e,n,!0)},c.prototype.removeListener=function(t,e,r,o){var u=n?n+t:t;if(!this._events[u])return this;if(!e)return i(this,u),this;var c=this._events[u];if(c.fn)c.fn!==e||o&&!c.once||r&&c.context!==r||i(this,u);else{for(var a=0,l=[],f=c.length;a<f;a++)(c[a].fn!==e||o&&!c[a].once||r&&c[a].context!==r)&&l.push(c[a]);l.length?this._events[u]=1===l.length?l[0]:l:i(this,u)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&i(this,e)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,t.exports=c}({get exports(){return go},set exports(t){go=t}});var _o=go;function wo(){let t,e,n=new Promise((function(){t=arguments[0],e=arguments[1]}));return n.resolve=t,n.reject=e,n}var mo=/\s/;var Oo=/^\s+/;function Ao(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&mo.test(t.charAt(e)););return e}(t)+1).replace(Oo,""):t}var ko=NaN,xo=/^[-+]0x[0-9a-f]+$/i,So=/^0b[01]+$/i,Po=/^0o[0-7]+$/i,zo=parseInt;function Bo(t){if("number"==typeof t)return t;if(Qn(t))return ko;if(g(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=g(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ao(t);var n=So.test(t);return n||Po.test(t)?zo(t.slice(2),n?2:8):xo.test(t)?ko:+t}var Eo=1/0,Io=17976931348623157e292;function Mo(t){return t?(t=Bo(t))===Eo||t===-Eo?(t<0?-1:1)*Io:t==t?t:0:0===t?t:0}function Fo(t){var e=Mo(t),n=e%1;return e==e?n?e-n:e:0}function Co(t){return"[object String]"===Object.prototype.toString.call(t)}function Do(t){return!(!Co(t)||""===t)}function Go(t){return t!=t}function No(t){let e=!1;if(Do(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Go(t))return!1;e=!0}return e}function $o(t){if(!No(t))return 0;return Mo(t)}function Uo(t){return!!No(t)&&(t=$o(t),"number"==typeof(e=t)&&e==Fo(e));var e}var To=a.isFinite,Lo=Math.min;var Ro=function(t){var e=Math[t];return function(t,n){if(t=Bo(t),(n=null==n?0:Lo(Fo(n),292))&&To(t)){var r=(dr(t)+"e").split("e");return+((r=(dr(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}("round"),qo=Ro;function Vo(t){if(!No(t))return 0;t=$o(t);let e=qo(t);return"0"===String(e)?0:e}let Wo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Ho=Wo.length;function Jo(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];var n;t=Uo(n=t)&&Vo(n)>0?Vo(t):32;for(let n=0;n<t;n++)e[n]=Wo[0|Math.random()*Ho];return e.join("")}var Ko="[object Boolean]";function Qo(t){return!0===(e=t)||!1===e||Z(e)&&j(e)==Ko;var e}function Xo(t){return"[object Array]"===Object.prototype.toString.call(t)}function Yo(t){return"[object Object]"===Object.prototype.toString.call(t)}function Zo(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(Yo(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!Co(t)||""!==t)}(t)||(!!function(t){return!!Xo(t)&&0===t.length}(t)||!!Go(t)))))}function tu(t){return!!Xo(t)&&(0!==t.length&&(1!==t.length||!Zo(t[0])))}function eu(t){if(Yo(t)){for(let e in t)return!0;return!1}return!1}function nu(t,e){var n;return(it(t)?W:sn)(t,"function"==typeof(n=e)?n:Ar)}function ru(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function ou(t,e){let n=wo();if(!Xo(t)&&!Yo(t))return n.reject("rs is not an array or object"),n;let r=!1;if(Yo(t)){r=!0;let e=[];nu(t,((t,n)=>{e.push({k:n,v:t})})),t=e}ru(e)||(e=function(t){return t});let o=-1,u=[];return t.reduce((function(t,n){return t.then((function(t){u.push(t),o+=1;let i=o,c=n;return r&&(i=n.k,c=n.v),ru(e)?e(c,i):c}))}),Promise.resolve()).then((function(t){var e,r,o,i;u.push(t),i=null==(e=u)?0:e.length,u=i?Er(e,(r=o||void 0===r?1:Fo(r))<0?0:r,i):[],n.resolve(u)})).catch((function(t){n.reject(t)})),n}return function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n.url||(n.url="mongodb://127.0.0.1:27017"),n.db||(n.db="worm"),n.cl||(n.cl="test");let r=gr(n,"autoGenPk");Qo(r)||(r=!0);let o=!1,u=!1,i=new _o,c=t.MongoClient;function a(t){let e=gr(t,"message");return Do(e)?e:String(t)}function l(t,e,n){try{i.emit("change",t,e,n)}catch(t){console.log(t)}}function f(t,e,n){try{i.emit("error",t,e,a(n))}catch(t){console.log(t)}}function s(t,e){if(!Do(t.id)){if(!r)throw new Error(`invalid data[${e}].id, autoGenPk is false`);t.id=Jo()}return t}function v(t){let e=gr(t,"writeErrors");return tu(e)?Pr(e,(function(t){return 11e3===gr(t,"code")||11e3===gr(t,"err.code")})):11e3===gr(t,"code")}async function p(t){o||(await t.createIndex({id:1},{unique:!0}),o=!0)}async function d(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0,n=!1,r=null;try{let n=e.find(t);r=await n.toArray()}catch(t){n=!0,r=t}return n?Promise.reject(r):r}return i.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=new c(n.url),o=null;try{let e=r.db(n.db).collection(n.cl).find(t);o=await e.toArray(),o=Br(o,(function(t){return t=Yr(t,"_id")}))}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e?(f("select",null,o),Promise.reject(o)):o},i.selectByPk=async function(t){let e=!1;if(!Do(t))return null;let r=new c(n.url),o=null;try{let e=r.db(n.db).collection(n.cl),u=await e.findOne({id:t},{projection:{_id:0}});o=eu(u)?u:null}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e?(f("selectByPk",null,o),Promise.reject(o)):o},i.insert=async function(t){let e=!1;if(!eu(t)&&!tu(t))return{n:0,nInserted:0,ok:1};t=un(t);let r=new c(n.url),o=null;try{await r.connect();let e=r.db(n.db).collection(n.cl);Xo(t)||(t=[t]),t=Br(t,s),await p(e);let u=jo(t),i=0;try{i=(await e.insertMany(t,{ordered:!1})).insertedCount}catch(t){if(!v(t))throw t;i=gr(t,"result.insertedCount",0)}o={n:u,nInserted:i,ok:1}}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e||l("insert",t,o),e?(f("insert",t,o),Promise.reject(o)):o},i.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!1;if(!eu(t)&&!tu(t))return[];t=un(t);let o=gr(e,"autoInsert",!0),u=new c(n.url),i=null;try{await u.connect();let e=u.db(n.db).collection(n.cl);Xo(t)||(t=[t]),t=Br(t,s),await p(e),i=await ou(t,(async t=>async function(t,e,n){let r=null,o=!1;for(let u=0;u<3;u++)try{let u=await t.updateOne({id:e.id},{$set:e},{upsert:n}),i=gr(u,"matchedCount",0),c=gr(u,"modifiedCount",0);gr(u,"upsertedCount",0)>0?(r={n:1,nInserted:1,nModified:0,ok:1},o=!0):r=i>0?{n:1,nInserted:0,nModified:c>0?1:0,ok:1}:{n:0,nInserted:0,nModified:0,ok:1};break}catch(t){if(v(t)&&u<2)continue;r={n:1,nInserted:0,nModified:0,ok:0,err:a(t)};break}return o&&l("insert",[e],r),0===r.ok&&f("save",[e],r.err),r}(e,t,o)))}catch(t){r=!0,i=t}finally{await u.close(),u=null}return r||l("save",t,i),r?(f("save",t,i),Promise.reject(i)):i},i.del=async function(t){let e=!1;if(!eu(t)&&!tu(t))return[];t=un(t);let r=new c(n.url),o=null;try{await r.connect();let e=r.db(n.db).collection(n.cl);Xo(t)||(t=[t]),o=await ou(t,(async t=>{let n=gr(t,"id"),r=null;if(Do(n))try{let t=gr(await e.deleteOne({id:n}),"deletedCount",0);r={n:t,nDeleted:t,ok:1}}catch(t){r={n:1,nDeleted:0,ok:0,err:a(t)}}else r={n:0,nDeleted:0,ok:0,err:`invalid id[${n}]`};return 0===r.ok&&f("del",[t],r.err),r}))}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e||l("del",t,o),e?(f("del",t,o),Promise.reject(o)):o},i.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=new c(n.url),o=null;try{let e=r.db(n.db).collection(n.cl),u=gr(await e.deleteMany(t),"deletedCount",0);o={n:u,nDeleted:u,ok:1}}catch(t){e=!0,o=t}finally{await r.close(),r=null}return e||l("delAll",null,o),e?(f("delAll",null,o),Promise.reject(o)):o},i.selectByPkGfs=async function(e){let r=!1;if(!Do(e))return null;let o=new c(n.url),u=null;try{u={id:e,u8a:await(async e=>{let r=wo(),u=o.db(n.db),i=new t.GridFSBucket(u,{chunkSizeBytes:10485760,bucketName:n.cl}),c=Buffer.from(""),a=i.openDownloadStreamByName(e);return a.on("data",(function(t){c=Buffer.concat([c,t])})),a.on("error",(function(t){r.reject(t)})),a.on("end",(function(){let t=new Uint8Array(c);c=null,r.resolve(t)})),r})(e)}}catch(t){"ENOENT"===gr(t,"code")?u=null:(r=!0,u=t)}finally{await o.close(),o=null}return r?(f("selectByPkGfs",null,u),Promise.reject(u)):u},i.insertGfs=async function(r){let o=!1;if(!eu(r)&&!tu(r))return{n:0,nInserted:0,ok:1};let i=new c(n.url),a=null;try{await i.connect();let o=i.db(n.db),c=new t.GridFSBucket(o,{chunkSizeBytes:10485760,bucketName:n.cl}),l=o.collection(`${n.cl}.chunks`);Xo(r)||(r=[r]),r=Br(r,(function(t,e){if(!function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}((t=s(t={...t},e)).u8a))throw new Error(`invalid data[${e}].u8a`);return t})),await async function(t){u||(await t.collection(`${n.cl}.files`).createIndex({filename:1},{unique:!0}),u=!0)}(o);let f=jo(r),p=0;await ou(r,(async t=>{let n=await function(t,n,r,o){let u=wo(),i=t.openUploadStream(r),c=i.id,a=new e.Readable;return a._read=()=>{},a.push(Buffer.from(o)),a.push(null),a.pipe(i).on("error",(function(t){v(t)?n.deleteMany({files_id:c}).then((function(){u.resolve(!1)})).catch((function(t){u.reject(t)})):u.reject(t)})).on("finish",(function(){u.resolve(!0)})),u}(c,l,t.id,t.u8a);n&&p++})),a={n:f,nInserted:p,ok:1}}catch(t){o=!0,a=t}finally{await i.close(),i=null}return o||l("insertGfs",r,a),o?(f("insertGfs",r,a),Promise.reject(a)):a},i.delGfs=async function(e){let r=!1;if(!eu(e)&&!tu(e))return[];let o=new c(n.url),u=null;try{await o.connect();let r=o.db(n.db),i=new t.GridFSBucket(r,{chunkSizeBytes:10485760,bucketName:n.cl});Xo(e)||(e=[e]),u=await ou(e,(async t=>{let e=gr(t,"id"),n=null;if(Do(e))try{let t=await d({filename:e},i),r=0;for(let e of t)await i.delete(e._id),r++;n={n:r>0?1:0,nDeleted:r,ok:1}}catch(t){n={n:1,nDeleted:0,ok:0,err:a(t)}}else n={n:0,nDeleted:0,ok:0,err:`invalid id[${e}]`};return 0===n.ok&&f("delGfs",[t],n.err),n}))}catch(t){r=!0,u=t}finally{await o.close(),o=null}return r||l("delGfs",e,u),r?(f("delGfs",e,u),Promise.reject(u)):u},i.delAllGfs=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=!1,o=new c(n.url),u=null;try{let r=o.db(n.db),i=new t.GridFSBucket(r,{chunkSizeBytes:10485760,bucketName:n.cl}),c=await d(e,i),a=Br(c,(function(t){return async function(t,e){await e.delete(t)}(t._id,i)}));await Promise.all(a);let l=jo(c);u={n:l,nDeleted:l,ok:1}}catch(t){r=!0,u=t}finally{await o.close(),o=null}return r||l("delAllGfs",null,u),r?(f("delAllGfs",null,u),Promise.reject(u)):u},i}}));
7
7
  //# sourceMappingURL=w-orm-mongodb.umd.js.map