mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
orm: add initial pg support (#9827)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import sqlite
|
||||
import mysql
|
||||
import pg
|
||||
|
||||
[table: 'modules']
|
||||
struct Module {
|
||||
@ -46,7 +47,8 @@ fn main() {
|
||||
|
||||
eprintln(modul)
|
||||
|
||||
mysql()
|
||||
// mysql()
|
||||
psql()
|
||||
}
|
||||
|
||||
fn mysql() {
|
||||
@ -82,3 +84,27 @@ fn mysql() {
|
||||
}
|
||||
eprintln(m)
|
||||
}
|
||||
|
||||
fn psql() {
|
||||
mut db := pg.connect(host: 'localhost', user: 'test', password: 'abc', dbname: 'test') or {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mod := Module{
|
||||
name: 'test'
|
||||
nr_downloads: 10
|
||||
creator: User{
|
||||
age: 21
|
||||
name: 'VUser'
|
||||
is_customer: true
|
||||
}
|
||||
}
|
||||
|
||||
sql db {
|
||||
create table Module
|
||||
}
|
||||
|
||||
sql db {
|
||||
insert mod into Module
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user