const flushUpdates = async (db: Db) => {
  if (!entitiesToUpdate.length) return;
  const entitiesCollection = db.collection('entities');
  const operations = entitiesToUpdate.map(entity => ({
    updateOne: {