From b7d3158acdc32aab38209a1aae6f1389937faef6 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 28 Feb 2021 01:51:03 -0600 Subject: update package-lock.json and remove weird code --- src/database.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/database.ts') 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 = new Map() let client: MongoClient let database: Db -let memberLeaderboardsCollection: Collection +let memberLeaderboardsCollection: Collection 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 = {} + 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 - }) + ) } -- cgit