title: SqlStorage Ionic 2 as a service/provider
body: <p>I have a provider in ionic two, and I have this:</p>
  
  <pre><code>getCategory() {
      this.storage.query('SELECT * FROM category')
        .then((data) =&gt; {
          var category = [];
          if (data.res.rows.length &gt; 0) {
            for (var i = 0; i &lt; data.res.rows.length; i++) {
              category.push({
                name: data.res.rows.item(i).name,
                type: data.res.rows.item(i).type,
                note: data.res.rows.item(i).note
              });
            }
          }
          // console.log(JSON.stringify(category)); 
          return category; // is this correct?
        }, (error) =&gt; {
          console.log('Error -&gt; ' + JSON.stringify(error.err));
        });
    }
  </code></pre>
  
  <p>Then I wish to do something like this in my pages, after injecting the service:</p>
  
  <pre><code>  constructor(nav, theservice) {
      this.nav = nav;
      this.service = theservice
      this.category = service.getCategory()
    }
  </code></pre>
  
  <p>How do I return something the results in order to be able to use? Trying the above returns nothing when I console log <code>this.category</code></p>
  
  <p>The tutorial on <a href="https://www.thepolyglotdeveloper.com/2015/12/use-sqlite-in-ionic-2-instead-of-local-storage/" rel="nofollow">how to use sqlite in ionic 2</a> has been helpful, but couldn't figure out how to convert them into services/providers.</p>