Tower Adapter
Datastore abstraction layer.
To abstract out some database like Cassandra, a REST API like Facebook, or even something like plain web crawling, so that it can be queried like any other resource, just implement the exec
method on a new adapter.
Installation
node.js:
$ npm install tower-adapter
browser:
$ component install tower/adapter
Examples
var adapter = ;
See one of these for a complete example:
Example custom REST adapter implementing the exec
method:
/** * Map of query actions to HTTP methods. */ var methods = find: 'GET' create: 'POST' update: 'PUT' remove: 'DELETE'; { var name = queryselects0resource; var method = methodsquerytype; var params = ; $;}; /** * Convert query constraints into query parameters. */ { var constraints = queryconstraints; var params = {}; constraints; return params;}
Map REST API objects to resources:
;
Specify (optional) how to serialize data types from JavaScript to the database-/service-specific format:
type'string' fn type'text' fn type'date' fn type'float' fn type'integer' fn type'number' fn type'boolean' fn type'bitmask' fn type'array' fn;
License
MIT