Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit b016bd786e6a7e769c5547088dbc33a29517454d @IgorMinar committed Nov 28, 2010
Showing with 44 additions and 0 deletions.
  1. +44 −0 angular-couch.js
44 angular-couch.js
@@ -0,0 +1,44 @@
+/*!
+ * angular couchdb service
+ *
+ * Copyright 2010, Igor Minar
+ * Licensed under the MIT license.
+ *
+ * This is an almost completely incomplete couchdb service, implemented
+ * as thin wrapper around jquery-couch.js.
+ *
+ * Over time it might turned out to be the best couchdb adapter for angular,
+ * but right now it's just a proof of concept.
+ *
+ */
+
+/**
+ * angular service exposing jquery couch for DI
+ */
+angular.service('jQueryCouch', function() {
+ return $.couch;
+});
+
+
+/**
+ * angular couch service
+ */
+angular.service('couch', function(jQueryCouch) {
+ var root = this;
+
+ return {
+ allDbs: function() {
+ var dbs = [];
+
+ jQueryCouch.allDbs({
+ success: function(allDbs) {
+ angular.copy(allDbs, dbs);
+ root.$eval();
+ }
+ });
+
+ return dbs;
+ }
+ }
+}, {$inject: ["jQueryCouch"], $creation: "eager-published"});
+

0 comments on commit b016bd7

Please sign in to comment.
Something went wrong with that request. Please try again.