// 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) }
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) }
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) }