# angular-pouchdb **Repository Path**: mirrors_nolanlawson/angular-pouchdb ## Basic Information - **Project Name**: angular-pouchdb - **Description**: Angular wrapper for PouchDB, making sure that callbacks are called within $rootScope.$apply(), and using $q promises instead of callbacks. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-11-23 - **Last Updated**: 2026-05-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AngularJS PouchDB Support A simple wrapper for PouchDB, to make integration into AngularJS applications a breeze. So what does it do? * It wraps PouchDB as a provider, allowing you to set global configuration before your dependencies are getting injected. * It uses `$q`-based promises instead of callbacks: `db.put({...})` will return a promise with the results, and no longer accepts a callback as the last parameter. The same goes for all other operations that normally required callbacks. * It will make sure Angular is aware of asynchronous updates. (It will make sure it uses `$rootScope.$apply()` in cases where it makes sense.) ## Usage var app = angular.module('app', ['pouchdb']); // Now if you dependency inject pouchdb in a service, you can: // Create a database var db = pouchdb.create('testdb'); // Destroy a database pouchdb.destroy('testdb'); // Add a document db.put({_id: 'foo', name: 'bar'}); // Handle the output db.put({_id: 'foo', name: 'bar'}).then(function(response) { // Do something with the response }).catch(function(error) { // Do something with the error }).finally(function() { // Do something when everything is done }); // To have a database as a dependency that you can inject in a service angular.factory('testdb', function(pouchdb) { return pouchdb.create('testdb'); }); angular.factory('testservice', function(testdb) { return { add: function(obj) { testdb.put(obj); } }; }); // To traverse and display all elements in a database (assuming that // database is exposed as testdb on the $scope object): // To traverse and display all elements in a database, and sort based on some fields