Skip to content

Commit 2f7c4f4

Browse files
authored
Merge pull request #35 from witheve/update/databases
Update databases doc
2 parents 4aaea35 + cafabf7 commit 2f7c4f4

File tree

13 files changed

+127
-24
lines changed

13 files changed

+127
-24
lines changed

handbook/browser/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
menu:
3+
main:
4+
parent: "Databases"
5+
title: "@browser"
6+
weight: 2
7+
---
8+
9+
# @browser
10+

handbook/databases.md

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
---
2-
menu:
3-
main:
4-
parent: "Core Language"
5-
title: "Databases"
6-
weight: 6
7-
---
8-
91
# Databases
102

11-
databases contain records
3+
Databases contain records
124

135
## Syntax
146

@@ -29,17 +21,38 @@ bind @database1, ..., @databaseN
2921

3022
If no database is provided with an action, then that action is performed on the default `@session` database.
3123

32-
## Special Databases
24+
## Creating and Searching Databases
25+
26+
You can create databases on-demand by simply committing a record to one. e.g.
27+
28+
```
29+
commit @my-database
30+
[#my-record]
31+
```
3332

34-
- `@session` - the default database, stores any record not associated explicitly with a database
33+
This block will create a new database called "my-database", which will contain the newly committed record. You can now search for this record in your new database:
3534

36-
- `@event` - holds records generated by user events in the DOM
35+
```
36+
search @my-database
37+
[#my-record]
3738
38-
- `@browser` - records stored in `@browser` are rendered as HTML by the browser
39+
bind @browser
40+
[#div text: "Found a record!"]
41+
```
42+
43+
## Special Databases
44+
45+
Eve has some built-in databases that have meaning to the runtime.
46+
47+
- [@session](../session) - the default database when no database is specified with an action.
48+
- [@view](../view) - records committed to `@view` are used to visualize data.
49+
- [@event](../event) - contains events originating from the DOM
50+
- [@browser](../browser) - Eve clients running in the browser render applicable records in this `@browser` as HTML elements.
51+
- [@http](../http) - Stores records representing HTTP requests and responses
3952

4053
## Examples
4154

42-
Display a message when the DOM is clicked
55+
Display the element that was clicked in the DOM
4356

4457
```eve
4558
search @event
@@ -49,6 +62,41 @@ commit @browser
4962
[#div text: "{{element}} was clicked."]
5063
```
5164

65+
Commit some data in `@session`, and then display it on a button click.
66+
67+
```
68+
commit
69+
[#for-display text: "Hello"]
70+
```
71+
72+
We are searching over three databases to complete this block.
73+
74+
- the `#click` is in `@event`
75+
- the `#button` is in `@browser`
76+
- the text for display is in `@session`. This needs to be made explicit; since we are searching in other databases, `@session` is not searched implicitly.
77+
78+
```
79+
search @event @browser @session
80+
[#click element: [#button]]
81+
[#for-display text]
82+
83+
commit @browser
84+
[#div text]
85+
```
86+
87+
This block could have been written with two searches for the same effect:
88+
89+
```
90+
search @event @browser
91+
[#click element: [#button]]
92+
93+
search
94+
[#for-display text]
95+
96+
commit @browser
97+
[#div text]
98+
```
99+
52100
## See Also
53101

54102
[search](../search) | [bind](../bind) | [commit](../commit)

handbook/datetime/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ menu:
33
main:
44
parent: "Standard Library"
55
title: "Date & Time"
6+
weight: 5
67
---
78

89
# Date & Time
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
menu:
33
main:
4-
parent: "Events"
4+
parent: "@event"
55
title: "click"
66
---
77

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
menu:
33
main:
4-
parent: "Standard Library"
5-
title: "Events"
4+
parent: "Databases"
5+
title: "@event"
6+
weight: 3
67
---
78

8-
# Events
9+
# @event
910

1011
[click](click) - a left-button mouse click event

handbook/general/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ menu:
33
main:
44
parent: "Standard Library"
55
title: "General"
6+
weight: 1
67
---
78

89
# General

handbook/http/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
menu:
3+
main:
4+
parent: "Databases"
5+
title: "@http"
6+
weight: 4
7+
---
8+
9+
# @http
10+

handbook/math/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ menu:
33
main:
44
parent: "Standard Library"
55
title: "Math"
6+
weight: 2
67
---
78

89
# Math
@@ -17,9 +18,10 @@ title: "Math"
1718
## General Math
1819

1920
- [abs](abs) - Absolute value
20-
- [ceil](ceil) - Round a number up
21+
- [ceiling](ceiling) - Round a number up
2122
- [floor](floor) - Round a number down
2223
- [round](round) - Round a number
24+
- [fix](fix) - Calculate the fix of a number
2325
- [mod](mod) - Modulo division
2426
- exp - The number `e` raised to a power
2527
- log - Calculate the logarithm of a number

handbook/session/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
menu:
3+
main:
4+
parent: "Databases"
5+
title: "@session"
6+
weight: 1
7+
---
8+
9+
# @session
10+

handbook/standard-library.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
---
2+
menu:
3+
main:
4+
parent: "Databases"
5+
title: "Standard Library"
6+
weight: 0
7+
---
8+
19
# Standard Library
210

11+
The Eve standard library of functions is globally available, meaning you don't have to reference a specific database to use these functions.
12+
313
## Description
414

15+
- [general](../general) - General functions
516
- [math](../math) - General mathematical and trigonometric functions
617
- [strings](../strings) - Functions that manipulate strings
718
- [statistics](../statistics) - Functions that calculate statistical measures on values

0 commit comments

Comments
 (0)