sendou.ink/scripts/snippets.txt
2019-05-13 23:51:44 +03:00

26 lines
513 B
Plaintext

-- 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])