aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/orm/README.md
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/orm/README.md
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/orm/README.md')
-rw-r--r--v_windows/v/vlib/orm/README.md85
1 files changed, 85 insertions, 0 deletions
diff --git a/v_windows/v/vlib/orm/README.md b/v_windows/v/vlib/orm/README.md
new file mode 100644
index 0000000..5cfa1fd
--- /dev/null
+++ b/v_windows/v/vlib/orm/README.md
@@ -0,0 +1,85 @@
+# ORM
+
+## Attributes
+
+### Structs
+
+- `[table: 'name']` sets a custom table name
+
+### Fields
+
+- `[primary]` sets the field as the primary key
+- `[unique]` sets the field as unique
+- `[unique: 'foo']` adds the field to a unique group
+- `[skip]` field will be skipped
+- `[sql: type]` sets the type which is used in sql (special type `serial`)
+- `[sql: 'name']` sets a custom column name for the field
+
+## Usage
+
+```v ignore
+struct Foo {
+ id int [primary; sql: serial]
+ name string [nonull]
+}
+```
+
+### Create
+
+```v ignore
+sql db {
+ create table Foo
+}
+```
+
+### Drop
+
+```v ignore
+sql db {
+ drop table Foo
+}
+```
+
+### Insert
+
+```v ignore
+var := Foo{
+ name: 'abc'
+}
+
+sql db {
+ insert var into Foo
+}
+```
+
+### Update
+
+```v ignore
+sql db {
+ update Foo set name = 'cde' where name == 'abc'
+}
+```
+
+### Delete
+```v ignore
+sql db {
+ delete from Foo where id > 10
+}
+```
+
+### Select
+```v ignore
+result := sql db {
+ select from Foo where id == 1
+}
+```
+```v ignore
+result := sql db {
+ select from Foo where id > 1 limit 5
+}
+```
+```v ignore
+result := sql db {
+ select from Foo where id > 1 order by id
+}
+```