🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

datacore

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datacore

Model library for RESTful API clients.

0.2.0
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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
# or
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) {/* do stuff */}]);

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.

Keywords

model

FAQs

Package last updated on 05 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts