Skip to content

Commit

Permalink
Add LIVE examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ce11an committed Aug 18, 2024
1 parent 8b8b2d6 commit 0433049
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/live.surql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- By default, SurrealDB will push the entire record over the websocket when created or updated, and just the record's ID when deleted.
LIVE SELECT * FROM person;

-- When using the DIFF mode, updates will be sent in the form of an array with JSON Patch messages.
LIVE SELECT DIFF FROM person;

-- You can optionally apply filters with the WHERE clause.
LIVE SELECT * FROM person WHERE age > 18;
91 changes: 91 additions & 0 deletions test/corpus/live.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
=====================================
Live select all fields from a table
=====================================

LIVE SELECT * FROM person;

---

(source_file
(expressions
(expression
(statement
(live_select_statement
(keyword_live)
(select_statement
(select_clause
(keyword_select)
(inclusive_predicate))
(from_clause
(keyword_from)
(value
(base_value
(identifier))))))))
(semi_colon)))

=====================================
Live select using DIFF
=====================================

LIVE SELECT DIFF FROM person;

---

(source_file
(expressions
(expression
(statement
(live_select_statement
(keyword_live)
(select_statement
(select_clause
(keyword_select)
(inclusive_predicate
(predicate
(value
(base_value
(identifier))))))
(from_clause
(keyword_from)
(value
(base_value
(identifier))))))))
(semi_colon)))

=====================================
Live select with a filter
=====================================

LIVE SELECT * FROM person WHERE age > 18;

---

(source_file
(expressions
(expression
(statement
(live_select_statement
(keyword_live)
(select_statement
(select_clause
(keyword_select)
(inclusive_predicate))
(from_clause
(keyword_from)
(value
(base_value
(identifier)))
(where_clause
(keyword_where)
(value
(binary_expression
(value
(base_value
(identifier)))
(operator)
(value
(base_value
(number
(int))))))))))))
(semi_colon)))

0 comments on commit 0433049

Please sign in to comment.