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
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ struct Customer {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
db := pg.connect(pg.Config{
|
||||
/*db := pg.connect(pg.Config{
|
||||
host: 'localhost' //'127.0.0.1'
|
||||
user: 'postgres'
|
||||
dbname: 'customerdb'
|
||||
@@ -58,7 +58,7 @@ fn main() {
|
||||
name: 'John Doe'
|
||||
nr_orders: 10
|
||||
}
|
||||
db.insert(nc)
|
||||
db.insert(nc)*/
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user