Exemplo n.º 1
0
func (b *Basics) Insert(a iface.Filter, data map[string]interface{}) (bson.ObjectId, error) {
	id := bson.NewObjectId()
	data["_id"] = id
	err := a.Insert(data)
	if err != nil {
		return "", err
	}
	if b.Ev != nil {
		q := map[string]interface{}{
			"_id": id,
		}
		filt := a.Clone().AddQuery(q)
		b.Ev.Fire("Inserted", filt)
		b.Ev.Fire(a.Subject()+"Inserted", filt)
	}
	return id, nil
}