Пример #1
0
func (d *DbMap) WhereBuilder(
	m Model,
	eq map[string]interface{},
	selectStr string,
) sq.SelectBuilder {
	if selectStr == "" {
		selectStr = "*"
	}
	return sq.Select(selectStr).From(d.TableName(m)).Where(sq.Eq(eq))
}
Пример #2
0
func (d *DbMap) FindWhere(holder Model, eq map[string]interface{}) error {
	q, args, err := sq.Select("*").From(d.TableName(holder)).
		Where(sq.Eq(eq)).ToSql()
	if err != nil {
		return err
	}
	d.Tracer.TraceOn()
	err = d.DbMap.SelectOne(holder, q, args...)
	d.Tracer.TraceOff()
	return err
}
Пример #3
0
func (d *DbMap) CountBuilder(m Model, eq map[string]interface{}) sq.SelectBuilder {
	return sq.Select("count(*)").From(d.TableName(m)).Where(sq.Eq(eq))
}