You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If no database is provided with an action, then that action is performed on the default `@session` database.
31
23
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
+
```
33
32
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:
35
34
36
-
-`@event` - holds records generated by user events in the DOM
35
+
```
36
+
search @my-database
37
+
[#my-record]
37
38
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
39
52
40
53
## Examples
41
54
42
-
Display a message when the DOM is clicked
55
+
Display the element that was clicked in the DOM
43
56
44
57
```eve
45
58
search @event
@@ -49,6 +62,41 @@ commit @browser
49
62
[#div text: "{{element}} was clicked."]
50
63
```
51
64
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:
0 commit comments