diff options
author | mat <github@matdoes.dev> | 2022-05-17 20:59:52 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-05-17 20:59:52 -0500 |
commit | 667b2d08638959d11bc2fbfa6e2b40b0e9834d6d (patch) | |
tree | 6868fe7848e2d57e32c3bf0991a69ef6fc3b8c00 /src/database.ts | |
parent | b577c9ace72b39daeff8e5c4278dba1230521625 (diff) | |
download | skyblock-api-667b2d08638959d11bc2fbfa6e2b40b0e9834d6d.tar.gz skyblock-api-667b2d08638959d11bc2fbfa6e2b40b0e9834d6d.tar.bz2 skyblock-api-667b2d08638959d11bc2fbfa6e2b40b0e9834d6d.zip |
add oldestDate field
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/database.ts b/src/database.ts index f3b8175..2392332 100644 --- a/src/database.ts +++ b/src/database.ts @@ -152,6 +152,8 @@ export interface ItemAuctionsSchemaBson { /** The id of the item */ _id: string auctions: SimpleAuctionSchemaBson[] + /** This is here so it can be indexed by Mongo, it can easily be figured out by getting the first item in auctions */ + oldestDate: number } let memberLeaderboardsCollection: Collection<DatabaseMemberLeaderboardItem> @@ -1111,7 +1113,7 @@ export async function updateAccount(discordId: string, schema: AccountSchema) { }, { $set: schema }, { upsert: true }) } -function toItemAuctionsSchema(i: ItemAuctionsSchemaBson) { +function toItemAuctionsSchema(i: ItemAuctionsSchemaBson): ItemAuctionsSchema { return { id: i._id, auctions: i.auctions.map(a => { @@ -1123,7 +1125,7 @@ function toItemAuctionsSchema(i: ItemAuctionsSchemaBson) { } } -function toItemAuctionsSchemaBson(i: ItemAuctionsSchema) { +function toItemAuctionsSchemaBson(i: ItemAuctionsSchema): ItemAuctionsSchemaBson { return { _id: i.id, auctions: i.auctions.map(a => { @@ -1132,6 +1134,7 @@ function toItemAuctionsSchemaBson(i: ItemAuctionsSchema) { id: createUuid(a.id) } }), + oldestDate: i.auctions[0]?.ts ?? 0 } } |