// Last retrieves a last record with the specified query condition and limit 1 from the database.
Last retrieves a last record with the specified query condition and limit 1 from the database.
// Last retrieves a last record with the specified query condition and limit 1 from the database .
func (r MigrationRepository) Last(ctx context.Context, query *migration.QueryCondition) (*migration.Log, error) {
	var where string
	var params []interface{}
	if query != nil && query.Where != nil {
		where = " WHERE status = $1 "
		params = append(params, query.Where.Status)
	}
	entity := &migration.Log{}
	err := r.db.DB().GetContext(ctx, entity, "SELECT * FROM " + migration.TableName + where + " ORDER BY id DESC LIMIT 1", params...)
	if err != nil {
		if err == sql.ErrNoRows {
			return nil, apperror.ErrNotFound
		}
	}
	return entity, nil
}
func ( r MigrationRepository ) Last ( ctx context . Context , query * migration . QueryCondition ) ( * migration . Log , error ) { var where string var params [ ] interface { } if query != nil && query . Where != nil { where = " " params = append ( params , query . Where . Status ) } entity := & migration . Log { } err := r . db . DB ( ) . GetContext ( ctx , entity , " " + migration . TableName + where + " " , params ... ) if err != nil { if err == sql . ErrNoRows { return nil , apperror . ErrNotFound } } return entity , nil }
Last retrieves a last record with the specified query condition and limit 1 from the database.
Last retrieves a last record with the specified query condition and limit 1 from the database .