'use strict'; /* globals db */ const cursor = db.users.find({ }); while (cursor.hasNext()) { const user = cursor.next(); print(`updating user: ${user.username}`); db.users.updateOne( { _id: user._id }, { $set: { stats: { uniqueVisitCount: 0, totalVisitCount: 0, }, }, }, ); }