Beispiel #1
0
func hasAdmin(f iface.Filter) error {
	q := map[string]interface{}{
		"level": 300,
	}
	f.AddQuery(q)
	c, err := f.Count()
	if err != nil {
		return err
	}
	if c > 0 {
		return fmt.Errorf("Site already has an admin.")
	}
	return nil
}
Beispiel #2
0
func (b *Basics) Get(a iface.Filter) ([]interface{}, *QueryInfo, error) {
	list, err := a.Find()
	if err != nil {
		return nil, nil, err
	}
	count, err := a.Count()
	if err != nil {
		return nil, nil, err
	}
	return list, &QueryInfo{
		count, a.Modifiers().Skip(),
		a.Modifiers().Limit(),
		a.Modifiers().Sort(),
	}, nil
}