MongoDB to the collection of documents into a random number

MongoDB to the collection of documents into a random number

db.movies.find().forEach(function(item){
	item.score = Math.random();
});

Note that the following wording is 错误的
a random number is the same value

// $set 必须要有
db.movies.update({},{$set:{"score",Math.random()*5}},{multi:true})
Published 92 original articles · won praise 18 · views 60000 +

Guess you like

Origin blog.csdn.net/qq_34120430/article/details/91359977