mongoose - fix assignment within condition