Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumMongoDBbucket and outlier patternsSingle-choice MCQ

You use the bucket pattern and append readings with `$push` until a bucket holds 200 items, then start a new bucket. Which single update operation is the idiomatic way to atomically append AND roll over to a new bucket only when there is room?

db.buckets.updateOne( { sensorId: 7, count: { $lt: 200 } }, { $push: { readings: r }, $inc: { count: 1 } }, { upsert: true } )