Hood.ie - Data not found using find

41 views Asked by At

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.

1

There are 1 answers

0
Gregor On

What you are looking for is

hoodie.store.find('teammember', theId)
  .done(function(object) { object.firstName })
  .fail(function(error) { alert(error.message) })

Most methods of Hoodie are asynchronous and return promises. A promise is an object with methods to which you can pass callback function. By standard, a Promise has .then & .catch methods, Hoodie also adds .done & .fail. .done(callback) gets called when the method succeeded. .fail(callback) gets called when it failed. .then(callback) and .catch(callback) additionally allow to chain the callbacks.

Find more information on Promises here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise And a great article on common gotchas here: http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html