okfn/recline — Issue #43: Datasets and Backends: finalize method for creation and use
Author: rgrp
Created: 2012-02-15 13:22:56+00:00
State: open

## What is backend?

Backend as Backend / DataProvider
Backend as DataSource

## Various options

### Option 1

Somewhere else in the system:

var backend = MyBackend(backendOnlyConfig)
my.backends[backend-id] = backend;

# later on
var dataset = Dataset(metadata);
dataset.backendConfig = {
type: 'my-backend',
url: http://mybackend.org/api
}

initialize:

this.backend_config = backend_config;
this.backend = my.backends[backend_config.type];
# all subsequent code will just use this.backend
# of course backends can access model.backend_config and, of course, model (if they want!)

### Option 2 (was Option 0 - sort of) - DataSource

var backend = MyBackend(backendConfig)
What is backendConfig? = backendOnly, datasetRelated (e.g. dataset api url)

var dataset = Dataset(metadataConfig, backend)

metadata = id, title, url

### Option 3 - Backend (for many DataSources)

var backend = MyBackend(backendOnlyConfig)
var dataset = Dataset(metadata, backend);
( Or: var dataset = Dataset(metadata, backend, backendInfo) )

## Option 4

dataset = Dataset(metadata = {}, backend_config={})

[dataset = CKANDataset(metdata)]

JC: i construct a dataset (and I don't need to know about backends ...) -- why wouldn't sufficient information to create / find its relevant backend.

Either in metadata:

url = backend url
api_url =
backend_type