// UpdateUserFields allows to update one or more user field
UpdateUserFields allows to update one or more user field
// UpdateUserFields allows to update one or more user field
func (db *Mngo) UpdateUserFields(userID string, fields params.M) error {
	c := db.database.Collection(models.UsersCollection)
	result, err := c.UpdateOne(context.TODO(), bson.M{"_id": userID}, fields, options.Update().SetUpsert(false))
	if err != nil {
		log.Fatal(err)
		return helpers.NewError(http.StatusInternalServerError, "user_update_failed", "Failed to update the user", err)
	}
	if result.MatchedCount != 0 {
		fmt.Println("matched and replaced an existing user")
		return nil
	}
	if result.UpsertedCount != 0 {
		fmt.Printf("UpdateUser: inserted a new document with ID %v\n", result.UpsertedID)
		return nil
	}
	return nil
}
func ( db * Mngo ) UpdateUserFields ( userID string , fields params . M ) error { c := db . database . Collection ( models . UsersCollection ) result , err := c . UpdateOne ( context . TODO ( ) , bson . M { " " : userID } , fields , options . Update ( ) . SetUpsert ( false ) ) if err != nil { log . Fatal ( err ) return helpers . NewError ( http . StatusInternalServerError , " " , " " , err ) } if result . MatchedCount != 0 { fmt . Println ( " " ) return nil } if result . UpsertedCount != 0 { fmt . Printf ( " \n " , result . UpsertedID ) return nil } return nil }
UpdateUserFields allows to update one or more user field
UpdateUserFields allows to update one or more user field