Exemplo n.º 1
0
// the result of the query is put in the passed struct.
// returns true if a result was found, false if no result
func FindById(DB db.IDb, table *db.Table, instance interface{}, id int64) (bool, error) {
	logger.CallerAt(1).Debugf("DAOUtils.FindById: %v", id)

	keyColumn := table.GetKeyColumns().Enumerator().Next().(*db.Column)

	return DB.Query(table).
		All().
		Where(keyColumn.Matches(id)).
		SelectTo(instance)
}
Exemplo n.º 2
0
func FindAll(DB db.IDb, table *db.Table, instance interface{}) (coll.Collection, error) {
	logger.CallerAt(1).Debugf("DAOUtils.FetchAll")

	deletion := table.GetDeletionColumn()

	q := DB.Query(table).All()
	if deletion != nil {
		q.Where(deletion.Matches(NOT_DELETED))
	}

	return q.ListOf(instance)
}
Exemplo n.º 3
0
func FindAllWithDeleted(DB db.IDb, table *db.Table, instance interface{}) (coll.Collection, error) {
	logger.CallerAt(1).Debugf("DAOUtils.FindAllWithDeleted")

	return DB.Query(table).All().ListOf(instance)
}