diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-02-16 21:40:58 +0100 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-02-16 21:40:58 +0100 |
commit | 20660444fd9a20c192301b62f4ef284c8f507b55 (patch) | |
tree | 6dbb2a32f21234874e1f09377dd1295cc6591576 | |
parent | :bug: fix database (diff) | |
download | server-20660444fd9a20c192301b62f4ef284c8f507b55.tar.xz |
:bug: fix Mongodb BigInt
-rw-r--r-- | dist/util/MongoBigInt.js | 2 | ||||
-rw-r--r-- | dist/util/MongoBigInt.js.map | 2 | ||||
-rw-r--r-- | src/util/MongoBigInt.ts | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/dist/util/MongoBigInt.js b/dist/util/MongoBigInt.js index 7dae718e..c026f77a 100644 --- a/dist/util/MongoBigInt.js +++ b/dist/util/MongoBigInt.js @@ -38,6 +38,8 @@ class LongSchema extends mongoose_1.default.SchemaType { return val; if ("" === val) return null; + if (typeof val === "bigint") + return mongoose_1.default.mongo.Long.fromString(val.toString()); if (val instanceof mongoose_1.default.mongo.Long) return BigInt(val.toString()); if (val instanceof Number || "number" == typeof val) diff --git a/dist/util/MongoBigInt.js.map b/dist/util/MongoBigInt.js.map index 5b0c8caa..1e79dbe3 100644 --- a/dist/util/MongoBigInt.js.map +++ b/dist/util/MongoBigInt.js.map @@ -1 +1 @@ -{"version":3,"file":"MongoBigInt.js","sourceRoot":"","sources":["../../src/util/MongoBigInt.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAEhC,MAAM,UAAW,SAAQ,kBAAQ,CAAC,UAAU;IAA5C;;QACQ,yBAAoB,GAAG;YAC7B,GAAG,EAAE,IAAI,CAAC,YAAY;YACtB,IAAI,EAAE,IAAI,CAAC,YAAY;YACvB,GAAG,EAAE,IAAI,CAAC,YAAY;YACtB,IAAI,EAAE,IAAI,CAAC,YAAY;YACvB,GAAG,EAAE,IAAI,CAAC,YAAY;YACtB,G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,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,YAAY,CAAC,YAAoB,EAAE,KAAU;QAC5C,IAAI,OAAO,CAAC;QACZ,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,EAAE;YAC3B,aAAa;YACb,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;YAClD,IAAI,CAAC,OAAO,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC,CAAC;aAC7D;YACD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACjC;aAAM;YACN,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC/B;IACF,CAAC;CACD;AAED,UAAU,CAAC,IAAI,GAAG,kBAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;AAC3C,UAAU,CAAC,GAAG,GAAG,kBAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;AACzC,UAAU,CAAC,GAAG,GAAG,kBAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;AAazC,kBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AACxC,kBAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,kBAAQ,CAAC,KAAK,CAAC,IAAI,CAAC"} \ No newline at end of file diff --git a/src/util/MongoBigInt.ts b/src/util/MongoBigInt.ts index cc185bed..e16d087a 100644 --- a/src/util/MongoBigInt.ts +++ b/src/util/MongoBigInt.ts @@ -33,7 +33,7 @@ class LongSchema extends mongoose.SchemaType { cast(val: any, scope?: any, init?: any) { if (null === val) return val; if ("" === val) return null; - + if (typeof val === "bigint") return mongoose.mongo.Long.fromString(val.toString()); if (val instanceof mongoose.mongo.Long) return BigInt(val.toString()); if (val instanceof Number || "number" == typeof val) return BigInt(val); if (!Array.isArray(val) && val.toString) return BigInt(val.toString()); |