-- Add size of the array to MongoDB collection -- addFlex: async () => { await Player.aggregate( [ { $addFields: { weaponsCount: { $size: "$weapons" } , }, }, { $out: "players" } ] ) return "ok" -- React timer -- useEffect(() => { const timeout = setTimeout(() => { setCurrentTime(new Date(Math.floor(Date.now() / 1000))) }, 1000) return () => { clearTimeout(timeout) } }, [currentTime])