1

so I'm working on an angular + stamplay project and so far it has been going great however I'm in need of limiting a collection response to the currently logged in user.

Here is what I have:

  function all() {
      var def = $q.defer();

      // instanticate a new product collection from the stamplay js sdk
      var firms = new Stamplay.Cobject('firms').Collection;

      firms.fetch()
          .then(function() {
              def.resolve(firms);
          });

      return def.promise;
  }

And here is the documentation: https://github.com/Stamplay/stamplay-js-sdk#query

The current user object is in scope and the above does return all of the firms, I'm just not sure how to limit the above results, in this case firms, to those created by the current user.

Thanks in advance for any tips you can provide!

1 Answers1

1

To return all of the items for that user you can modify you function to:

function all() {
      var def = $q.defer();

      var firms = new Stamplay.Cobject('firms').Collection;

      // Add the equalTo fetch param arg before calling fetch.
      firms.equalTo("owner", [id_of_user]).fetch()
          .then(function() {
              def.resolve(firms);
          });

      return def.promise;
  }