func (e *Entries) getTaken(a iface.Filter, from int64) (evenday.DaySchedule, error) { b := a.Clone() q := map[string]interface{}{ "day": dateToString(from), } b.AddQuery(q) res, err := b.Find() if err != nil { return evenday.DaySchedule{}, err } gen := []interface{}{} for _, v := range res { gen = append(gen, v) } return evenday.GenericToDaySchedule(gen) }
func (b *Basics) Insert(a iface.Filter, data map[string]interface{}) (iface.Id, error) { id := b.Db.NewId() data["_id"] = id err := a.Insert(data) if err != nil { return nil, err } if b.Hooks != nil { q := map[string]interface{}{ "_id": id, } filt := a.Clone().AddQuery(q) b.Hooks.Select("Inserted").Fire(filt) b.Hooks.Select(a.Subject() + "Inserted").Fire(filt) } return id, nil }