added toBigInt and BigInt getters to bitfields

This commit is contained in:
notsapinho
2021-04-08 11:43:26 -03:00
parent f01fe1ba3a
commit e8c097ef27
9 changed files with 32 additions and 9 deletions
+12 -1
View File
@@ -7,7 +7,12 @@ const uri = process.env.MONGO_URL || "mongodb://localhost:27017/fosscord?readPre
console.log(`[DB] connect: ${uri}`);
const connection = mongoose.createConnection(uri, { autoIndex: true, useNewUrlParser: true, useUnifiedTopology: true });
const connection = mongoose.createConnection(uri, {
autoIndex: true,
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
});
export default <Connection>connection;
@@ -56,6 +61,12 @@ export class MongooseCache extends EventEmitter {
}
};
changeStream = (pipeline: any) => {
this.pipeline = pipeline;
this.destroy();
this.init();
};
convertResult = (obj: any) => {
if (obj instanceof Long) return BigInt(obj.toString());
if (typeof obj === "object") {
+1 -1
View File
@@ -44,7 +44,7 @@ class LongSchema extends mongoose.SchemaType {
if (val instanceof Number || "number" == typeof val) return BigInt(val);
if (!Array.isArray(val) && val.toString) return BigInt(val.toString());
// @ts-ignore
//@ts-ignore
throw new SchemaType.CastError("Long", val);
}
+1 -1
View File
@@ -4,7 +4,7 @@ import Config from "./Config";
export function checkToken(token: string): Promise<any> {
return new Promise((res, rej) => {
jwt.verify(token, Config.getAll().api.security.jwtSecret, JWTOptions, (err, decoded: any) => {
jwt.verify(token, Config.getAll()?.api?.security?.jwtSecret, JWTOptions, (err, decoded: any) => {
if (err || !decoded) return rej("Invalid Token");
return res(decoded);
+1
View File
@@ -5,3 +5,4 @@ export * from "./MessageFlags";
export * from "./Permissions";
export * from "./Snowflake";
export * from "./UserFlags";
export * from "./toBigInt"
+3
View File
@@ -0,0 +1,3 @@
export default function toBigInt(string: String): BigInt {
return BigInt(string);
}