From e5b35dae0a0f6322cff88e45e0d21fe227ec8b1c Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Mon, 1 Jan 2024 23:10:40 -0500 Subject: [PATCH] vault backup: 2024-01-01 23:10:40 --- Databases/SurrealDB/Command line interface.md | 3 ++- Databases/SurrealDB/Syntax.md | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Databases/SurrealDB/Command line interface.md b/Databases/SurrealDB/Command line interface.md index 67c7041..5033ae4 100644 --- a/Databases/SurrealDB/Command line interface.md +++ b/Databases/SurrealDB/Command line interface.md @@ -33,4 +33,5 @@ The HTTP protocol must be used in the export process ## SQL mode -SurrealDB has a SQL-like (not compatible with ANSI SQL) language one can use for running (or piping) SurrealQL queries. You can find the syntax and some examples over [here](./Syntax). \ No newline at end of file +SurrealDB has a SQL-like (not compatible with ANSI SQL) language one can use for running (or piping) SurrealQL queries. You can find the syntax and some examples over [here](./Syntax). + diff --git a/Databases/SurrealDB/Syntax.md b/Databases/SurrealDB/Syntax.md index ce889ea..c99db0d 100644 --- a/Databases/SurrealDB/Syntax.md +++ b/Databases/SurrealDB/Syntax.md @@ -74,4 +74,20 @@ SELECT ->likes->friend.name AS friends FROM person:tobie; -- Use the result of a subquery as a returned field SELECT *, (SELECT * FROM events WHERE type = 'activity' LIMIT 5) AS history FROM user; ``` -### `UPDATE` \ No newline at end of file +### `UPDATE` examples +```SQL +-- Update all records in a table +UPDATE person SET skills += ['breathing']; + +-- Update or create a record with a specific numeric id +UPDATE person:100 SET name = 'Tobie', company = 'SurrealDB', skills = ['Rust', 'Go', 'JavaScript']; + +-- Update or create a record with a specific string id +UPDATE person:tobie SET name = 'Tobie', company = 'SurrealDB', skills = ['Rust', 'Go', 'JavaScript']; + +-- Update just a single record +-- Using the ONLY keyword, just an object for the record in question will be returned. +-- This, instead of an array with a single object. +UPDATE ONLY person:tobie SET name = 'Tobie', company = 'SurrealDB', skills = ['Rust', 'Go', 'JavaScript']; +``` +