Simple schema.

Richard Newman 2016-10-18 10:11:58 -07:00
parent 2f2e7ba3ea
commit f27200dd5b

@ -48,4 +48,31 @@ await db.q(
[?page :page/url ?url]
[?page :page/visitedAt ?date]]`,
{"limit": 2, "order-by": [["_max_date", "desc"]]});
```
## Simple schema
Datomish's JS API exposes a simple schema interface through `db.ensureSchema`. This accepts input with simplified string keys and values, like this:
```
{
"name": "pages",
"attributes": [
{"name": "page/url",
"type": "string",
"cardinality": "one",
"unique": "identity",
"doc": "A page's URL."},
{"name": "page/title",
"type": "string",
"cardinality": "one",
"fulltext": true,
"doc": "A page's title."},
{"name": "page/content",
"type": "string",
"cardinality": "one",
"fulltext": true,
"doc": "A snapshot of the page's content. Should be plain text."},
]
}
```