Skip to content

Commit

Permalink
Given up on tlvince angular-pouchdb. Sticking with wspringer version
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Zen committed May 8, 2015
1 parent be574df commit 8b84b53
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 87 deletions.
311 changes: 232 additions & 79 deletions angular-pouchdb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ng-pouchdb-binding.js
Expand Up @@ -2,15 +2,15 @@ angular.module('pouchdb')

// This service binds the scope expression to a pouchdb/couchdb database.
// There is no promise provided
.factory('pouchBindingSimple', ['$timeout', '$parse', 'pouchDB', function($timeout, $parse, pouchDB) {
.factory('pouchBindingSimple', ['$timeout', '$parse', 'pouchdb', function($timeout, $parse, pouchDB) {
var stopTheWatch;
return function(reference, scope, expression) {
var getObj = $parse(expression);
var setObj = getObj.assign;
if (!setObj) {
throw new Error('expression ' + expression + 'must be assignable');
}
var database = new pouchDB(reference);
var database = pouchDB.create(reference);
database.get(expression).then(
function(res) {
setObj(scope, res);
Expand Down
4 changes: 2 additions & 2 deletions ng-pouchdb-collection.js
@@ -1,6 +1,6 @@
angular.module('pouchdb')

.factory('pouchCollection', ['$timeout', 'pouchDB', function($timeout, pouchDB) {
.factory('pouchCollection', ['$timeout', 'pouchdb', function($timeout, pouchDB) {

/**
* @class item in the collection
Expand All @@ -23,7 +23,7 @@ angular.module('pouchdb')
return function(collectionUrl) {
var collection = [];
var indexes = {};
var db = collection.$db = new pouchDB(collectionUrl);
var db = collection.$db = pouchDB.create(collectionUrl);

function getIndex(prevId) {
return prevId ? indexes[prevId] + 1 : 0;
Expand Down
8 changes: 4 additions & 4 deletions test/ng-pouchdb-spec.js
Expand Up @@ -6,22 +6,22 @@ describe('ng-pouchdb Binding', function() {

beforeEach(module('pouchdb'));

beforeEach(inject(function (_$rootScope_, _$compile_, _pouchDB_, _pouchBindingSimple_) {
beforeEach(inject(function (_$rootScope_, _$compile_, _pouchdb_, _pouchBindingSimple_) {
$rootScope = _$rootScope_;
$compile = _$compile_;
pouchDB = _pouchDB_;
pouchDB = _pouchdb_;
pouchBindingSimple = _pouchBindingSimple_;
}));

//TODO: This test is not working
it('should store properties in PouchDb', function (done) {
var expectation = {foo: 'bar', baz: 'qux'};
$rootScope.testObj = value;
$rootScope.testObj = expectation;
var expression = 'testObj';
var refDb = 'test-db';
pouchBindingSimple(refDb, $rootScope, expression);

var db = new pouchDB(refDb);
var db = pouchDB.create(refDb);

db.get(expression).then(function (value) {
console.log("GOT HERE!!!"); // Not yet getting here
Expand Down

0 comments on commit 8b84b53

Please sign in to comment.