From f6504b6d78547052f5686409724ded181e3d1ded Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 2 Jul 2022 15:49:52 -0500 Subject: mongodb treats undefined as null --- src/database.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/database.ts b/src/database.ts index 4d2eb4d..d513256 100644 --- a/src/database.ts +++ b/src/database.ts @@ -1135,10 +1135,12 @@ function toItemAuctionsSchemaBson(i: ItemAuctionsSchema): ItemAuctionsSchemaBson _id: i.id, sbId: i.sbId, auctions: i.auctions.map(a => { - return { + const newA: SimpleAuctionSchemaBson = { ...a, bin: a.bin ? true : undefined } + if (newA.bin === undefined) delete newA.bin + return newA }), // we sort by oldestDate to get the volume sold, but we don't want brand new items with like no data having a high frequency oldestDate: i.auctions.length > 10 ? i.auctions[0]?.ts ?? 0 : 0 -- cgit