// Update updates user if exists
Update updates user if exists
// Update updates user if exists
func (d *MongoUserDao) Update(u *s.User) error {
	collection := d.Client.Database(d.DatabaseName).Collection(collectionName)
	updateBody := bson.M{}
	if u.FirstName != "" {
		updateBody["firstName"] = u.FirstName
	}
	if u.LastName != "" {
		updateBody["lastName"] = u.LastName
	}
	if u.Email != "" {
		updateBody["email"] = u.Email
	}
	if u.Password != "" {
		updateBody["password"] = u.Password
	}
	_, err := collection.UpdateOne(d.Ctx, bson.M{"_id": u.ID}, bson.M{"$set": updateBody})
	return err
}
func ( d * MongoUserDao ) Update ( u * s . User ) error { collection := d . Client . Database ( d . DatabaseName ) . Collection ( collectionName ) updateBody := bson . M { } if u . FirstName != " " { updateBody [ " " ] = u . FirstName } if u . LastName != " " { updateBody [ " " ] = u . LastName } if u . Email != " " { updateBody [ " " ] = u . Email } if u . Password != " " { updateBody [ " " ] = u . Password } _ , err := collection . UpdateOne ( d . Ctx , bson . M { " " : u . ID } , bson . M { " " : updateBody } ) return err }
Update updates user if exists
Update updates user if exists