Skip to content

Commit

Permalink
Merge pull request #35 from witheve/update/databases
Browse files Browse the repository at this point in the history
Update databases doc
ibdthor authored Dec 8, 2016
2 parents 4aaea35 + cafabf7 commit 2f7c4f4
Showing 13 changed files with 127 additions and 24 deletions.
10 changes: 10 additions & 0 deletions handbook/browser/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
menu:
main:
parent: "Databases"
title: "@browser"
weight: 2
---

# @browser

76 changes: 62 additions & 14 deletions handbook/databases.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
---
menu:
main:
parent: "Core Language"
title: "Databases"
weight: 6
---

# Databases

databases contain records
Databases contain records

## Syntax

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

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

## Special Databases
## Creating and Searching Databases

You can create databases on-demand by simply committing a record to one. e.g.

```
commit @my-database
[#my-record]
```

- `@session` - the default database, stores any record not associated explicitly with a database
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:

- `@event` - holds records generated by user events in the DOM
```
search @my-database
[#my-record]
- `@browser` - records stored in `@browser` are rendered as HTML by the browser
bind @browser
[#div text: "Found a record!"]
```

## Special Databases

Eve has some built-in databases that have meaning to the runtime.

- [@session](../session) - the default database when no database is specified with an action.
- [@view](../view) - records committed to `@view` are used to visualize data.
- [@event](../event) - contains events originating from the DOM
- [@browser](../browser) - Eve clients running in the browser render applicable records in this `@browser` as HTML elements.
- [@http](../http) - Stores records representing HTTP requests and responses

## Examples

Display a message when the DOM is clicked
Display the element that was clicked in the DOM

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

Commit some data in `@session`, and then display it on a button click.

```
commit
[#for-display text: "Hello"]
```

We are searching over three databases to complete this block.

- the `#click` is in `@event`
- the `#button` is in `@browser`
- 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.

```
search @event @browser @session
[#click element: [#button]]
[#for-display text]
commit @browser
[#div text]
```

This block could have been written with two searches for the same effect:

```
search @event @browser
[#click element: [#button]]
search
[#for-display text]
commit @browser
[#div text]
```

## See Also

[search](../search) | [bind](../bind) | [commit](../commit)
1 change: 1 addition & 0 deletions handbook/datetime/index.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ menu:
main:
parent: "Standard Library"
title: "Date & Time"
weight: 5
---

# Date & Time
2 changes: 1 addition & 1 deletion handbook/events/click.md → handbook/event/click.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
menu:
main:
parent: "Events"
parent: "@event"
title: "click"
---

7 changes: 4 additions & 3 deletions handbook/events/index.md → handbook/event/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
menu:
main:
parent: "Standard Library"
title: "Events"
parent: "Databases"
title: "@event"
weight: 3
---

# Events
# @event

[click](click) - a left-button mouse click event
1 change: 1 addition & 0 deletions handbook/general/index.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ menu:
main:
parent: "Standard Library"
title: "General"
weight: 1
---

# General
10 changes: 10 additions & 0 deletions handbook/http/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
menu:
main:
parent: "Databases"
title: "@http"
weight: 4
---

# @http

4 changes: 3 additions & 1 deletion handbook/math/index.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ menu:
main:
parent: "Standard Library"
title: "Math"
weight: 2
---

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

- [abs](abs) - Absolute value
- [ceil](ceil) - Round a number up
- [ceiling](ceiling) - Round a number up
- [floor](floor) - Round a number down
- [round](round) - Round a number
- [fix](fix) - Calculate the fix of a number
- [mod](mod) - Modulo division
- exp - The number `e` raised to a power
- log - Calculate the logarithm of a number
10 changes: 10 additions & 0 deletions handbook/session/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
menu:
main:
parent: "Databases"
title: "@session"
weight: 1
---

# @session

11 changes: 11 additions & 0 deletions handbook/standard-library.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
---
menu:
main:
parent: "Databases"
title: "Standard Library"
weight: 0
---

# Standard Library

The Eve standard library of functions is globally available, meaning you don't have to reference a specific database to use these functions.

## Description

- [general](../general) - General functions
- [math](../math) - General mathematical and trigonometric functions
- [strings](../strings) - Functions that manipulate strings
- [statistics](../statistics) - Functions that calculate statistical measures on values
1 change: 1 addition & 0 deletions handbook/statistics/index.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ menu:
main:
parent: "Standard Library"
title: "Statistics"
weight: 4
---

# Statistics
8 changes: 3 additions & 5 deletions handbook/strings/index.md
Original file line number Diff line number Diff line change
@@ -3,12 +3,10 @@ menu:
main:
parent: "Standard Library"
title: "Strings"
weight: 3
---

# Strings

- [length](length)
- [concatenate](concat)
- [replace](replace)
- [split](split)
- [join](join)
- [split](split) - split a string into tokens
- [join](join) - join tokens into a string
10 changes: 10 additions & 0 deletions handbook/view/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
menu:
main:
parent: "Databases"
title: "@view"
weight: 5
---

# @view

0 comments on commit 2f7c4f4

Please sign in to comment.