// UpdateWorlds updates some number of worlds entries, passed as arg
UpdateWorlds updates some number of worlds entries, passed as arg
// UpdateWorlds updates some number of worlds entries passed as arg
func (m Mongo) UpdateWorlds(selectedWorlds Worlds) error {
	for _, selectedWorld := range selectedWorlds {
		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
		defer cancel()
		selectedWorld.RandomNumber = rand.Intn(worldsCount) + 1
		if _, err := m.worlds.UpdateOne(
			ctx,
			bson.M{"_id": selectedWorld.ID},
			bson.M{"$set": bson.M{"randomNumber": selectedWorld.RandomNumber}},
		); err != nil {
			log.Fatalf("Error updating world with id: %s", err.Error())
		}
	}
	return nil
}
func ( m Mongo ) UpdateWorlds ( selectedWorlds Worlds ) error { for _ , selectedWorld := range selectedWorlds { ctx , cancel := context . WithTimeout ( context . Background ( ) , 10 * time . Second ) defer cancel ( ) selectedWorld . RandomNumber = rand . Intn ( worldsCount ) + 1 if _ , err := m . worlds . UpdateOne ( ctx , bson . M { " " : selectedWorld . ID } , bson . M { " " : bson . M { " " : selectedWorld . RandomNumber } } , ) ; err != nil { log . Fatalf ( " " , err . Error ( ) ) } } return nil }
UpdateWorlds updates some number of worlds entries, passed as arg
UpdateWorlds updates some number of worlds entries passed as arg