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

@@ -4850,18 +4850,18 @@ db := sqlite.connect('customers.db')!
// )
sql db {
create table Customer
}
}!
// select count(*) from customers
nr_customers := sql db {
select count from Customer
}
}!
println('number of all customers: ${nr_customers}')
// V syntax can be used to build queries
uk_customers := sql db {
select from Customer where country == 'uk' && nr_orders > 0
}
}!
println(uk_customers.len)
for customer in uk_customers {
println('${customer.id} - ${customer.name}')
@@ -4874,7 +4874,7 @@ new_customer := Customer{
}
sql db {
insert new_customer into Customer
}
}!
```
For more examples and the docs, see [vlib/orm](https://github.com/vlang/v/tree/master/vlib/orm).