summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Database.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/util/Database.ts b/src/util/Database.ts
index 1ebfbd12..2304378c 100644
--- a/src/util/Database.ts
+++ b/src/util/Database.ts
@@ -1,9 +1,12 @@
 import "./MongoBigInt";
-import mongoose, { Collection } from "mongoose";
+import mongoose, { Collection, Connection } from "mongoose";
 import { ChangeStream, ChangeEvent, Long } from "mongodb";
 import EventEmitter from "events";
+const uri = process.env.MONGO_URL || "mongodb://localhost:27017/fosscord?readPreference=secondaryPreferred";
 
-export default mongoose.connection;
+const connection = mongoose.createConnection(uri, { autoIndex: true });
+
+export default <Connection>connection;
 
 export interface MongooseCache {
 	on(event: "delete", listener: (id: string) => void): this;