Example #1
0
func (r *HostRepo) Create(host *host.Host) error {
	id := bson.NewObjectId()
	host.CreatedAt = time.Now()
	host.ModifiedAt = time.Now()
	_, err := r.coll.UpsertId(id, host)
	if err != nil {
		return err
	}

	host.Id = id

	return nil
}
Example #2
0
func (r *HostRepo) Update(host *host.Host) error {
	host.ModifiedAt = time.Now()
	err := r.coll.UpdateId(host.Id, host)
	if err != nil {
		return err
	}

	return nil
}