From 12f6afebc90f9b54f5fe2e916b3ff7f6d1842523 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Fri, 29 Jun 2012 15:49:43 +0100 Subject: [PATCH] [#168,docs/backend][s]: bring backend example up to date. --- docs/backends.markdown | 8 ++++++++ example-backends.markdown | 15 +++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/backends.markdown b/docs/backends.markdown index a7af4a04..72e22069 100644 --- a/docs/backends.markdown +++ b/docs/backends.markdown @@ -11,11 +11,19 @@ root: ../ +Backends connect Dataset and Documents to data from a specific 'Backend' data +source. They provide methods for loading and saving Datasets and individuals +Documents as well as for bulk loading via a query API and doing bulk transforms +on the backend. + Backends come in 2 flavours: 1. Loader backends - only implement fetch method. The data is then cached in a Memory.Store on the Dataset and interacted with there. This is best for sources which just allow you to load data or where you want to load the data once and work with it locally. 2. Store backends - these support fetch, query and, if write-enabled, save. These are suitable where the backend contains a lot of data (infeasible to load locally - for examples a million rows) or where the backend has capabilities you want to take advantage of. + +# Backend API + Backend modules must implement the following API: {% highlight javascript %} diff --git a/example-backends.markdown b/example-backends.markdown index 918156ba..cf754c1c 100644 --- a/example-backends.markdown +++ b/example-backends.markdown @@ -30,20 +30,18 @@ source. They provide methods for loading and saving Datasets and individuals Documents as well as for bulk loading via a query API and doing bulk transforms on the backend. -You can instantiate a backend directly e.g. +You can use a backend directly e.g. {% highlight javascript %} -var backend = recline.Backend.ElasticSearch(); +var backend = recline.Backend.ElasticSearch.fetch({url: ...}); {% endhighlight %} But more usually the backend will be created or loaded for you by Recline and all you need is provide the identifier for that Backend e.g. {% highlight javascript %} var dataset = recline.Model.Dataset({ - ... - }, - 'backend-identifier' -); + backend: 'backend-identifier' +}); {% endhighlight %}
@@ -53,7 +51,6 @@ How do you know the backend identifier for a given Backend? It's just the name o ### Included Backends -* [memory: Memory Backend (local data)](docs/backend/memory.html) * [elasticsearch: ElasticSearch Backend](docs/backend/elasticsearch.html) * [dataproxy: DataProxy Backend (CSV and XLS on the Web)](docs/backend/dataproxy.html) * [gdocs: Google Docs (Spreadsheet) Backend](docs/backend/gdocs.html) @@ -71,8 +68,6 @@ This is as per the [quickstart](example-quickstart.html) but the set of files is - - @@ -110,5 +105,5 @@ a bespoke chooser and a Kartograph (svg-only) map. ## Writing your own backend Writing your own backend is easy to do. Details of the required API are in the -[Backend documentation](docs/backend/base.html). +[Backend documentation](docs/backends.html).