dbms #
Constants #
const (
migrations_up = [
$embed_file('migrations/001-initial/up.sql'),
$embed_file('migrations/002-rename-to-targets/up.sql'),
$embed_file('migrations/003-target-url-type/up.sql'),
$embed_file('migrations/004-nullable-branch/up.sql'),
$embed_file('migrations/005-repo-path/up.sql'),
]
migrations_down = [
$embed_file('migrations/001-initial/down.sql'),
$embed_file('migrations/002-rename-to-targets/down.sql'),
$embed_file('migrations/003-target-url-type/down.sql'),
$embed_file('migrations/004-nullable-branch/down.sql'),
$embed_file('migrations/005-repo-path/down.sql'),
]
)
fn init #
pub fn init(db_path string) !VieterDb
init initializes a database & adds the correct tables.
fn row_into #
pub fn row_into[T](row sqlite.Row) T
row_into[T] converts an sqlite.Row into a given type T by parsing each field from a string according to its type.
struct MigrationVersion #
struct MigrationVersion {
id int [primary]
version int
}
struct TargetsIterator #
pub struct TargetsIterator {
conn sqlite.DB
filter TargetFilter
window_size int = 32
mut:
window []Target
window_index u64
// Offset in entire list of unfiltered targets
offset int
// Offset in filtered list of targets
filtered_offset u64
started bool
done bool
}
Iterator providing a filtered view into the list of targets currently stored in the database. It replaces functionality usually performed in the database using SQL queries that can't currently be used due to missing stuff in V's ORM.
fn (TargetsIterator) advance_window #
fn (mut ti TargetsIterator) advance_window()
advance_window moves the sliding window over the filtered list of targets until it either reaches the end of the list of targets, or has encountered a non-empty window.
fn (TargetsIterator) next #
pub fn (mut ti TargetsIterator) next() ?Target
next returns the next target, if possible.
fn (TargetsIterator) collect #
pub fn (mut ti TargetsIterator) collect() []Target
collect consumes the entire iterator & returns the result as an array.
struct VieterDb #
pub struct VieterDb {
conn sqlite.DB
}
fn (VieterDb) add_build_log #
pub fn (db &VieterDb) add_build_log(log BuildLog) int
add_build_log inserts the given BuildLog into the database.
fn (VieterDb) add_target #
pub fn (db &VieterDb) add_target(target Target) int
add_target inserts the given target into the database.
fn (VieterDb) delete_build_log #
pub fn (db &VieterDb) delete_build_log(id int)
delete_build_log delete the BuildLog with the given ID from the database.
fn (VieterDb) delete_target #
pub fn (db &VieterDb) delete_target(target_id int)
delete_target deletes the target with the given id from the database.
fn (VieterDb) get_build_log #
pub fn (db &VieterDb) get_build_log(id int) ?BuildLog
get_build_log tries to return a specific BuildLog.
fn (VieterDb) get_build_logs #
pub fn (db &VieterDb) get_build_logs(filter BuildLogFilter) []BuildLog
get_build_logs returns all BuildLog's in the database.
fn (VieterDb) get_build_logs_for_target #
pub fn (db &VieterDb) get_build_logs_for_target(target_id int) []BuildLog
get_build_logs_for_target returns all BuildLog's in the database for a given target.
fn (VieterDb) get_target #
pub fn (db &VieterDb) get_target(target_id int) ?Target
get_target tries to return a specific target.
fn (VieterDb) target_exists #
pub fn (db &VieterDb) target_exists(target_id int) bool
target_exists is a utility function that checks whether a target with the given id exists.
fn (VieterDb) targets #
pub fn (db &VieterDb) targets(filter TargetFilter) TargetsIterator
targets returns an iterator allowing filtered access to the list of targets.
fn (VieterDb) update_target #
pub fn (db &VieterDb) update_target(target_id int, params map[string]string)
update_target updates any non-array values for a given target.
fn (VieterDb) update_target_archs #
pub fn (db &VieterDb) update_target_archs(target_id int, archs []TargetArch)
update_target_archs updates a given target's arch value.