diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 01:51:03 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 01:51:03 -0600 |
commit | b7d3158acdc32aab38209a1aae6f1389937faef6 (patch) | |
tree | 94dbd5ef141f83e8b24feb6ff372dc6b13c306ea /src/database.ts | |
parent | 5f08f21d8c55b849775c55957164c7697e464efe (diff) | |
download | skyblock-api-b7d3158acdc32aab38209a1aae6f1389937faef6.tar.gz skyblock-api-b7d3158acdc32aab38209a1aae6f1389937faef6.tar.bz2 skyblock-api-b7d3158acdc32aab38209a1aae6f1389937faef6.zip |
update package-lock.json and remove weird code
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/database.ts b/src/database.ts index a1178bc..a7f8f0d 100644 --- a/src/database.ts +++ b/src/database.ts @@ -4,7 +4,7 @@ import * as constants from './constants' import * as cached from './hypixelCached' -import { Collection, Db, FilterQuery, MongoClient } from 'mongodb' +import { Collection, Db, MongoClient } from 'mongodb' import NodeCache from 'node-cache' import { CleanMember } from './cleaners/skyblock/member' @@ -26,7 +26,7 @@ const cachedLeaderboards: Map<string, any> = new Map() let client: MongoClient let database: Db -let memberLeaderboardsCollection: Collection<LeaderboardItem> +let memberLeaderboardsCollection: Collection<any> async function connect() { if (!process.env.db_uri) @@ -84,7 +84,7 @@ export async function fetchMemberLeaderboard(name: string) { if (cachedLeaderboards.has(name)) return cachedLeaderboards.get(name) // typescript forces us to make a new variable and set it this way because it gives an error otherwise - const query: FilterQuery<any> = {} + const query = {} query[`stats.${name}`] = { '$exists': true } const sortQuery: any = {} @@ -130,16 +130,18 @@ export async function updateDatabaseMember(member: CleanMember) { const leaderboardAttributes = getMemberLeaderboardAttributes(member) - await memberLeaderboardsCollection.updateOne({ - uuid: member.uuid - }, { - '$set': { - 'stats': leaderboardAttributes, - 'last_updated': new Date() + await memberLeaderboardsCollection.updateOne( + { + uuid: member.uuid + }, { + '$set': { + 'stats': leaderboardAttributes, + 'last_updated': new Date() + } + }, { + upsert: true } - }, { - upsert: true - }) + ) } |