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:
@@ -36,7 +36,7 @@ fn (mut app App) service_auth(username string, password string) !string {
|
||||
|
||||
users := sql db {
|
||||
select from User where username == username
|
||||
}
|
||||
}!
|
||||
user := users.first()
|
||||
if user.username != username {
|
||||
return error('user not found')
|
||||
|
||||
@@ -37,7 +37,7 @@ fn (mut app App) service_get_all_products_from(user_id int) ![]Product {
|
||||
|
||||
results := sql db {
|
||||
select from Product where user_id == user_id
|
||||
}
|
||||
}!
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ fn (mut app App) service_get_all_user() ![]User {
|
||||
|
||||
results := sql db {
|
||||
select from User
|
||||
}
|
||||
}!
|
||||
|
||||
return results
|
||||
}
|
||||
@@ -59,7 +59,7 @@ fn (mut app App) service_get_user(id int) !User {
|
||||
|
||||
results := sql db {
|
||||
select from User where id == id
|
||||
}
|
||||
}!
|
||||
|
||||
return results.first()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user