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:
@ -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')
|
||||
|
@ -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')
|
||||
}
|
||||
|
@ -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')
|
||||
|
Reference in New Issue
Block a user