From f27200dd5b4836cab920a80327523400ee429827 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Tue, 18 Oct 2016 10:11:58 -0700 Subject: [PATCH] Simple schema. --- Differences-from-Datomic.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Differences-from-Datomic.md b/Differences-from-Datomic.md index 9f67cbd..a1d0558 100644 --- a/Differences-from-Datomic.md +++ b/Differences-from-Datomic.md @@ -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."}, + ] +} ``` \ No newline at end of file