added toBigInt and BigInt getters to bitfields
This commit is contained in:
+12
-1
@@ -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") {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from "./MessageFlags";
|
||||
export * from "./Permissions";
|
||||
export * from "./Snowflake";
|
||||
export * from "./UserFlags";
|
||||
export * from "./toBigInt"
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function toBigInt(string: String): BigInt {
|
||||
return BigInt(string);
|
||||
}
|
||||
Reference in New Issue
Block a user