mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
orm: add unique fields & add drop table stmt (#9684)
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user