func (m *FeedManager) Create(raw *feed.FeedItem) (*feed.FeedItem, error) { // TODO (m0sth8): add validation raw.Id = bson.NewObjectId() raw.Created = time.Now().UTC() raw.Updated = raw.Created if err := m.col.Insert(raw); err != nil { return nil, err } return raw, nil }
func (m *FeedManager) Enrich(item *feed.FeedItem) error { switch item.Type { case feed.TypeScan: if item.ScanId != "" && item.Scan == nil { obj, err := m.manager.Scans.GetById(item.ScanId) if err != nil { return err } item.Scan = obj } } return nil }
func (m *FeedManager) Update(obj *feed.FeedItem) error { obj.Updated = time.Now().UTC() return m.col.UpdateId(obj.Id, obj) }