summary refs log tree commit diff
path: root/dist/util/MongoBigInt.js
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-03-03 21:24:34 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-03-03 21:24:34 +0100
commitd85701a5b7fde84fa482de49c0f06a9ec90e1815 (patch)
treeec5b97c9098ad89ef146641589f5ded4dce902f3 /dist/util/MongoBigInt.js
parent:construction: custom permissions (diff)
downloadserver-d85701a5b7fde84fa482de49c0f06a9ec90e1815.tar.xz
:art: getPermission cache
Diffstat (limited to 'dist/util/MongoBigInt.js')
-rw-r--r--dist/util/MongoBigInt.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/dist/util/MongoBigInt.js b/dist/util/MongoBigInt.js

index c026f77a..70d1a62f 100644 --- a/dist/util/MongoBigInt.js +++ b/dist/util/MongoBigInt.js
@@ -22,26 +22,30 @@ class LongSchema extends mongoose_1.default.SchemaType { }; } handleSingle(val) { - return this.cast(val); + return this.cast(val, null, null, "handle"); } handleArray(val) { var self = this; return val.map(function (m) { - return self.cast(m); + return self.cast(m, null, null, "handle"); }); } checkRequired(val) { return null != val; } - cast(val, scope, init) { + cast(val, scope, init, type) { if (null === val) return val; if ("" === val) return null; - if (typeof val === "bigint") + if (typeof val === "bigint" && type === "query") { return mongoose_1.default.mongo.Long.fromString(val.toString()); - if (val instanceof mongoose_1.default.mongo.Long) + } + if (val instanceof mongoose_1.default.mongo.Long) { + if (type === "handle" || init == false) + return val; return BigInt(val.toString()); + } if (val instanceof Number || "number" == typeof val) return BigInt(val); if (!Array.isArray(val) && val.toString) @@ -60,7 +64,7 @@ class LongSchema extends mongoose_1.default.SchemaType { return handler.call(this, value); } else { - return this.cast($conditional); + return this.cast($conditional, null, null, "query"); } } }