Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.mongodb.MongoClient
- import org.bson.Document as doc
- def mongoClient = new MongoClient()
- def database = mongoClient.getDatabase('school')
- def collection = database.getCollection('students')
- collection.find()
- .projection(['scores':1] as doc)
- .each {
- def minScore = it.scores.findAll { it.type == 'homework'}.min { it.score }
- it.scores.remove(minScore)
- collection.updateOne(['_id':it._id] as doc, ['$set':['scores':it.scores]] as doc)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement