factoryng
An all-in-one angularjs factory that wraps multiple backends.
Why?
AngularJS is great and there are tons of amazing backends like pouch, firebase, etc... Unfortunately, some of your backend's structure ultimately leaks into your angular controllers. This means that your controllers are then tightly coupled with your backend, which makes it difficult to switch your backend without modifying your controllers.
With factoryng, you can feel free to develop your controllers with little regard to your backend. If you choose to switch backends, include a new backend or use multiple backends you don't have to worry about rewriting your controllers. Sure, your current backend works great for you now, but will it still be your top choice in 6 months?
Live Demo: Projects (Kitchen Sink)
Live Demo: Contacts (Simple Example)
And, the Contacts Demo Source Code
Usage
Download via bower
bower install factoryng
Download via npm
npm install factoryng
Include the scripts
You must include factoryng.js, any adapters that you are using and any underlying adapter technologies, e.g.
API
Let Adapter be the adapter, e.g. Pouchyng, DeltaPouchyng, Firying, etc...
Instantiate
var adapter = name url sortBy;
e.g.
var adapter = 'todos' 'http://127.0.0.1:5984' yngutilsASC;
or:
var adapter = 'todos' 'http://127.0.0.1:5984' { return asomeAttr - bsomeAttr;};
Bind
adapter;
e.g.
// Bind to $scope and load all docsadapter;
Create Doc
adapter;
e.g.
adapter;
Update Doc
adapter;
e.g.
adapter;
Prioritize/Order Doc
adapter;
e.g.
adapter;
Remove Doc
adapter;
e.g.
adapter;
For Each
adapter;
e.g.
adapter;
At
adapter;
e.g.
adapter; // first docadapter; // second doc
Get
adapter;
e.g.
adapter; // get doc with $id = '123'
Contributing
A few adapters have already been written. Is yours missing? Can you help us write it?