feat: adding target returns id of added entry

This commit is contained in:
Jef Roosens 2022-09-05 10:10:02 +02:00
parent 3e0a2584fa
commit 7b59277931
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 11 additions and 7 deletions

View file

@ -38,10 +38,14 @@ pub fn (db &VieterDb) get_target(target_id int) ?Target {
}
// add_target inserts the given target into the database.
pub fn (db &VieterDb) add_target(repo Target) {
pub fn (db &VieterDb) add_target(repo Target) int {
sql db.conn {
insert repo into Target
}
inserted_id := db.conn.last_id() as int
return inserted_id
}
// delete_target deletes the target with the given id from the database.