diff --git a/libs/databases/mongodb.js b/libs/databases/mongodb.js index a553113575b..5f1274d3adb 100644 --- a/libs/databases/mongodb.js +++ b/libs/databases/mongodb.js @@ -24,6 +24,16 @@ class IMongoDB extends Interface { async connect () { this.client = await client.connect(config.database.mongodb.url, { poolSize: _.get(config, 'database.mongodb.poolSize', 5) }) + + // create indexes + let db = this.client.db(this.dbName) + await db.collection('users.bits').createIndex('timestamp') + await db.collection('users.tips').createIndex('timestamp') + await db.collection('users').createIndex('username') + await db.collection('cache').createIndex('key') + await db.collection('api.stats').createIndex('timestamp') + await db.collection('stats').createIndex('whenOnline') + this.connected = true }