EzDevInfo.com

hoodie.js

hoodie super power to the frontend! hood.ie

Hood.ie - Data not found using find

Just started to use Hood.ie for a web app, however am facing issues in obtaining some data.

I want to get the data and then simply do something like

hoodie.store.find('teammember', theId).firstName;

Is this possible?

Thanks.


Source: (StackOverflow)

Sync data between couchdb and a Lotus Notes Database

I have to migrate a Lotus Application to couchdb/hood.ie.

anyone seen a kind of sync between Lotus Notes/Domino and couchdb?

thx

Pitt


Source: (StackOverflow)

Advertisements

Grunt and hood.ie test database

I'm currently running my test suite on AngularJS using Grunt, Karma, Jasmine and Protractor. The database library I'm using is hood.ie, which is a library on top of CouchDB. I start hood.ie using the following code in my Gruntfile:

hoodie: {
  start: {
    options: {
      callback: function(config) {
        grunt.config.set('connect.proxies.0.port', config.stack.couch.port);
      }
    }
  }
},

However, I would like to have a separate database for running tests, which automatically resets afterwards. This way, the production data won't conflict with the tests.

How should I approach this? I would assume there's some kind of standard way of doing this, as I can imagine other people have come across the same problem, but I'm unable to find anything on the internet.


Source: (StackOverflow)

Hood.ie Find and Update Data

Just started using Hood.ie - have a question with finding and updating data.

I have a type called 'who' within which i have stored a 'personId' and 'time'. What i want to do is search 'who' for 'personId' I specify then update record which is empty.

So i can do basic updates like

hoodie.store.update('whosin', clicked_id, { timeOut: Date() });

but how do i do the more complicated one with hood.ie as above - something roughly like:

hoodie.store.update('whosin', personID = clicked_id, { timeOut: Date() WHERE timeOut = "" });

Source: (StackOverflow)

How can I configure Polymer's platinum-sw-* to NOT cache one URL path?

How can I configure Polymer's platinum-sw-cache or platinum-sw-fetch to cache all URL paths except for /_api, which is the URL for Hoodie's API? I've configured a platinum-sw-fetch element to handle the /_api path, then platinum-sw-cache to handle the rest of the paths, as follows:

<platinum-sw-register auto-register
                      clients-claim
                      skip-waiting
                      on-service-worker-installed="displayInstalledToast">
  <platinum-sw-import-script rel='nofollow' href="custom-fetch-handler.js"></platinum-sw-import-script>
  <platinum-sw-fetch handler="HoodieAPIFetchHandler"
                 path="/_api(.*)"></platinum-sw-fetch>
  <platinum-sw-cache default-cache-strategy="networkFirst"
                     precache-file="precache.json"/>
  </platinum-sw-cache>
</platinum-sw-register>

custom-fetch-handler.js contains the following. Its intent is simply to return the results of the request the way the browser would if the service worker was not handling the request.

var HoodieAPIFetchHandler = function(request, values, options){
  return fetch(request);
}

What doesn't seem to be working correctly is that after user 1 has signed in, then signed out, then user 2 signs in, then in Chrome Dev Tools' Network tab I can see that Hoodie regularly continues to make requests to BOTH users' API endpoints like the following:

http://localhost:3000/_api/?hoodieId=uw9rl3p
http://localhost:3000/_api/?hoodieId=noaothq

Instead, it should be making requests to only ONE of these API endpoints. In the Network tab, each of these URLs appears twice in a row, and in the "Size" column the first request says "(from ServiceWorker)," and the second request states the response size in bytes, in case that's relevant.

The other problem which seems related is that when I sign in as user 2 and submit a form, the app writes to user 1's database on the server side. This makes me think the problem is due to the app not being able to bypass the cache for the /_api route.

Should I not have used both platinum-sw-cache and platinum-sw-fetch within one platinum-sw-register element, since the docs state they are alternatives to each other?


Source: (StackOverflow)

AngularJS + Hoodie: How to do a correct data flow?

I would like to combine AngularJS and Hoodie, but I am not sure how to do it the correct way. Let's say I have a basic AngularJS controller

app.controller("c", function($scope) {
  $scope.table = [];

  $scope.onAdd = function(newEntry) {
      $scope.table.push(newEntry);
  };
});

After clicking on e.g.

<button ng-click="onAdd('test');">add</button>

Everything works as expected. But now I want to use Hoodie. Currently I am trying this:

app.controller("c", function($scope) {
  $scope.table = [];

  $scope.onAdd = function(newEntry) {
      $scope.table.push(newEntry);
  };

  hoodie.store.on('entries:add', $scope.onAdd);
});

and anywhere: hoodie.store.add("entries", tmpObject);

The onAdd() gets called and is inserted into the table array (verified in the developer console), but my html table (via ng-repeat="entry in table") is not updated.

First question: Do you know why? What do I think wrong here?

Second question: What would be a good way to combine Hoodie and AngularJS? Would it be better to $watch on the table and insert items into it and store it via Hoodie after getting a change or the other way around and add a new item to the hoodie.store and then on("entries:add") do some Angular stuff?

Thanks in advance!


Source: (StackOverflow)

Uncaught TypeError: this.hoodie.account.signUp is not a function

Why does my element throw the following error when it's served through an iron-component-page element (in a Polymer Seed Element demo), but not when served normally through my app?

Uncaught TypeError: this.hoodie.account.signUp is not a function

The demo is published at http://timblack1.github.io/hoodie-accountbar/components/hoodie-accountbar/.

this.hoodie should be created by hoodie.js, which does load according to Dev Tools' Network tab. But the this.hoodie object doesn't contain as many methods and attributes as it should, including the .account.signUp() method. this.hoodie.account exists, but only as an empty object.

I'm loading hoodie.js via a <script> tag in the hoodie-service element, which is loaded by hoodie-accountbar. Does the iron-component-page element do anything funny when it loads tags in a demo element? Or does hydrolysis?


Source: (StackOverflow)

hoodie app on nodejitsu: added %2f confounding couchdb request

I have deployed a basic tutorial hoodie app on nodejitsu (which works fine on my local server). Here is the url of my deployed app:

http://reggie.nodejitsu.com

A signup button is supposed to appear in the upper right hand corner after user login status is confirmed, which it does, but after a very, very long time.

Looking at the log file on nodejitsu, I see (personal detail redacted):

Streaming logging information

out Thu, 13 Nov 2014 18:51:25 GMT Starting Plugin: 'hoodie-plugin-users'
out Thu, 13 Nov 2014 18:51:25 GMT All plugins started.
err Thu, 13 Nov 2014 18:51:25 GMT { [Error: not_found
missing]

and then a little later:

_header: 'GET /_users/org.couchdb.user%3Aadmin%2F HTTP/1.1\r\nHost: xxxxxxxxx.iriscouch.com\r\nAccept: application/json\r\nAuthorization: Basic YWRtaW46bm9uY3JpdGljYWw=\r\nConnection: keep-alive\r\n\r\n',

and then a little later:

out Thu, 13 Nov 2014 18:51:25 GMT 
err Thu, 13 Nov 2014 18:51:25 GMT Error confirming user: Error: not_found
missing

If I request the endpoint /_users/org.couchdb.user%3Aadmin%2F from my nodejitsu couchdb instance directly, that fails with {"error":"not_found","reason":"missing"}. But if I remove the trailing encoded slash, /_users/org.couchdb.user%3Aadmin, I get the user returned as expected.

So it seems to me the trailing encoded slash (%2f) is messing up the authentication with couchdb, and then I presume the very long delay the app takes to figure out if the user is logged in to the app is resulting from a timeout trying access the database without the required credentials. But I do not know how to stop the trailing encoded slash from being added.

Have I diagnosed the issue correctly, and either way, how can I resolve this issue?

Thanks!


Source: (StackOverflow)

Hoodie - Update a CouchDB document (Node.js)

I'm handling charges and customers' subscriptions with Stripe, and I want to use these handlings as a Hoodie plugin.

Payments and customer's registrations and subscriptions appear normally in Stripe Dashboard, but what I want to do is update my _users database in CouchDB, to make sure customer's information are saved somewhere. What I want to do is updating the stripeCustomerId field in org.couchdb.user:user/bill document, from my _users database which creates when logging with Hoodie. And if it is possible, to create this field if it does not exist.

In hoodie-plugin's document, the update function seems pretty ambiguous to me.

// update a document in db
db.update(type, id, changed_attrs, callback)

I assume that type is the one which is mentioned in CouchDB's document, or the one we specify when we add a document with db.add(type, attrs, callback) for example.

id seems to be the doc id in couchdb. In my case it is org.couchdb.user:user/bill. But I'm not sure that it is this id I'm supposed to pass in my update function.

I assume that changed_attrs is a Javascript object with updated or new attributes in it, but here again I have my doubts.

So I tried this in my worker.js:

function handleCustomersCreate(originDb, task) {
    var customer = {
      card: task.card
    };
    if (task.plan) {
      customer.plan = task.plan;
    }

    stripe.customers.create(customer, function(error, response) {
      var db = hoodie.database(originDb);
      var o = {
        id: 'bill',
        stripeCustomerId: 'updatedId'

      };

      hoodie.database('_users').update('user', 'bill', o, function(error) {
        console.log('Error when updating');
        addPaymentCallback(error, originDb, task);
      });


      db.add('customers.create', {
        id: task.id,
        stripeType: 'customers.create',
        response: response,

      }, function(error) {
        addPaymentCallback(error, originDb, task);
      });
    });
  }

And between other messages, I got this error log:

TypeError: Converting circular structure to JSON

And my file is not updated : stripeCustomerId field stays null. I tried to JSON.stringify my o object, but It doesn't change a thing.

I hope than some of you is better informed than I am on this db.update function.


Source: (StackOverflow)