docs: add description of how to use a custom table name to the ORM example – (#12408)

pull/12418/head
Taras 2021-11-08 12:22:42 +02:00 committed by GitHub
parent 758c18a906
commit 15242d8082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -4009,8 +4009,9 @@ V's ORM provides a number of benefits:
```v
import sqlite
// sets a custom table name. Default is struct name (case-sensitive)
[table: 'customers']
struct Customer {
// struct name has to be the same as the table name (for now)
id int [primary; sql: serial] // a field named `id` of integer type must be the first field
name string [nonull]
nr_orders int
@ -4030,7 +4031,7 @@ sql db {
create table Customer
}
// select count(*) from Customer
// select count(*) from customers
nr_customers := sql db {
select count from Customer
}