mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
orm: add unique fields & add drop table stmt (#9684)
This commit is contained in:
parent
b0b3c51658
commit
67d8639917
6 changed files with 101 additions and 7 deletions
|
@ -10,15 +10,14 @@ struct Module {
|
|||
|
||||
struct User {
|
||||
id int [primary; sql: serial]
|
||||
age int
|
||||
name string [nonull]
|
||||
is_customer bool
|
||||
age int [unique: 'user']
|
||||
name string [unique]
|
||||
is_customer bool [unique: 'user']
|
||||
skipped_string string [skip]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
db := sqlite.connect(':memory:') or { panic(err) }
|
||||
db.exec('drop table if exists User')
|
||||
sql db {
|
||||
create table Module
|
||||
}
|
||||
|
@ -40,6 +39,10 @@ fn main() {
|
|||
select from Module where id == 1
|
||||
}
|
||||
|
||||
sql db {
|
||||
drop table Module
|
||||
}
|
||||
|
||||
eprintln(modul)
|
||||
|
||||
mysql()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue