diff options
author | mat <github@matdoes.dev> | 2022-05-17 18:12:51 +0000 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-05-17 18:12:51 +0000 |
commit | 767c17c494b2302ac10f0657ad280832350413db (patch) | |
tree | b6755f353fe5512fd8422d733c83402b2491c4aa /src/database.ts | |
parent | 5101e436bd2acfb6efdffe5c8c723511ab735153 (diff) | |
download | skyblock-api-767c17c494b2302ac10f0657ad280832350413db.tar.gz skyblock-api-767c17c494b2302ac10f0657ad280832350413db.tar.bz2 skyblock-api-767c17c494b2302ac10f0657ad280832350413db.zip |
add auctionitems endpoint
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/database.ts b/src/database.ts index 3aafd05..a8dd1a4 100644 --- a/src/database.ts +++ b/src/database.ts @@ -1110,6 +1110,17 @@ export async function updateItemAuction(auction: ItemAuctionsSchema) { }, { $set: auction }, { upsert: true }) } +/** + * Fetches the SkyBlock ids of all the items in the auctions database. This method is slow and should be cached! + */ +export async function fetchItemsAuctionsIds(): Promise<string[]> { + const docs = await itemAuctionsCollection?.aggregate([ + // this removes everything except the _id + { $project: { _id: true } } + ]).toArray() + return docs.map(r => r._id) +} + export async function fetchServerStatus() { return await database.admin().serverStatus() |