summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-16 21:16:56 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-16 21:16:56 +0100
commit57746da87206f31c8612b975df37305fb2a5e0b7 (patch)
treeb3f1774d3e4921571e95a40035875ad4b01da145 /src/util
parent:bug: fix database (diff)
downloadserver-57746da87206f31c8612b975df37305fb2a5e0b7.tar.xz
:bug: fix database
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;