From 9d7afa4e307d9e54ecd4bea370f7153b817a3ede Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 21 Jun 2020 16:09:35 +0200 Subject: [PATCH] doc: update ORM syntax --- doc/docs.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 4fae90b7f8..ef32808ae9 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1470,27 +1470,27 @@ struct Customer { // struct name has to be the same as the table name (for now) country string } -db := pg.connect(db_name, db_user) +db := sqlite.connect('customers.db') // select count(*) from Customer -nr_customers := db.select count from Customer +nr_customers := sql db { select count from Customer } println('number of all customers: $nr_customers') // V syntax can be used to build queries // db.select returns an array -uk_customers := db.select from Customer where country == 'uk' && nr_orders > 0 +uk_customers := sql db { select from Customer where country == 'uk' && nr_orders > 0 } println(uk_customers.len) for customer in uk_customers { println('$customer.id - $customer.name') } // by adding `limit 1` we tell V that there will be only one object -customer := db.select from Customer where id == 1 limit 1 +customer := sql db { select from Customer where id == 1 limit 1 } println('$customer.id - $customer.name') // insert a new customer new_customer := Customer{name: 'Bob', nr_orders: 10} -db.insert(new_customer) +sql db { insert new_customer into Customer } ``` ## vfmt