Description
Model library for RESTful API clients, similar in spirit to ActiveRecord,
Backbone.Model, and others. It's simple and lightweight, uses ES6 class-based
approach, and has good code coverage via tests and Flow.
Note: version 0.2.0 is a complete rewrite. I've slimmed the library down
tremendously to focus on the most vital features. See 1.0.x to
compare.
Datacore is packaged in a format compatible with both AngularJS and CommonJS.
What's a Model Library?
Rich web applications consume and generate lots of data. It's common to organise
it by breaking it up into well-defined "models" that correspond to resources on
a RESTful API backend. A model library handles the boilerplate code so you don't
have to.
Installation
AngularJS
Install via bower:
bower i --save datacore
bower i --save-dev datacore
The angular build uses $q
and $http
instead of es6-promise
and xhttp
,
but still depends on lodash
. Make sure you have window._
available.
You'll need main-bower-files in your
build system to organise dependency order. Datacore specifies angular and lodash
as dependencies but doesn't bundle them. main-bower-files makes sure they'll be
loaded in the right order.
In your app's configuration, require the module Datacore
and the factory
Record
.
angular.module('MyApp', ['Datacore'])
.factory('BaseModel', ['Record', function (Record) {}]);
Record is the base class for your models.
CommonJS
To use CommonJS, you need a build system with
browserify or webpack.
Install via npm:
npm i --save-dev datacore
Then require in your application:
var Record = require('datacore');
Record is the base class for your models.
ToDo / WIP.
The documentation needs a complete rewrite now.