mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +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:
parent
9addede0ea
commit
8452644ec3
67 changed files with 479 additions and 354 deletions
|
@ -9,5 +9,5 @@ struct Article {
|
|||
pub fn (app &App) find_all_articles() []Article {
|
||||
return sql app.db {
|
||||
select from Article
|
||||
}
|
||||
} or { []Article{} }
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ fn main() {
|
|||
}
|
||||
sql app.db {
|
||||
create table Article
|
||||
}
|
||||
}!
|
||||
vweb.run(app, 8081)
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ pub fn (mut app App) new_article(title string, text string) vweb.Result {
|
|||
println(article)
|
||||
sql app.db {
|
||||
insert article into Article
|
||||
}
|
||||
} or {}
|
||||
|
||||
return app.redirect('/')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue