1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

orm: enforce that queries always return a Result, a query-resulting array can be used as a V array in place. (#17871)

This commit is contained in:
walking devel
2023-04-04 05:23:06 +00:00
committed by GitHub
parent 9addede0ea
commit 8452644ec3
67 changed files with 479 additions and 354 deletions

View File

@ -33,7 +33,7 @@ fn (mut app App) service_auth(username string, password string) !string {
users := sql db {
select from User where username == username
}
}!
if users.len == 0 {
return error('user not found')

View File

@ -66,7 +66,7 @@ pub fn (mut app App) delete() vweb.Result {
sql db {
drop table User
}
} or { panic(err) }
return app.text('Successfully deleted table')
}

View File

@ -33,7 +33,7 @@ fn (mut app App) service_add_user(username string, password string) !User {
users := sql db {
select from User where username == username limit 1
}
}!
return users.first()
}
@ -50,7 +50,7 @@ fn (mut app App) service_get_user_by_id(user_id int) !User {
users := sql db {
select from User where id == user_id
}
}!
return users.first()
}
@ -67,7 +67,7 @@ fn (mut app App) service_get_all_user() ![]User {
results := sql db {
select from User
}
}!
return results
}
@ -84,7 +84,7 @@ fn (mut app App) service_get_by_username(username string) !User {
results := sql db {
select from User where username == username
}
}!
if results.len == 0 {
return error('User not found')