aboutsummaryrefslogtreecommitdiff
path: root/src/database.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-17 18:12:51 +0000
committermat <github@matdoes.dev>2022-05-17 18:12:51 +0000
commit767c17c494b2302ac10f0657ad280832350413db (patch)
treeb6755f353fe5512fd8422d733c83402b2491c4aa /src/database.ts
parent5101e436bd2acfb6efdffe5c8c723511ab735153 (diff)
downloadskyblock-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.ts11
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()