ParseReact icon indicating copy to clipboard operation
ParseReact copied to clipboard

Support count queries

Open mikemintz opened this issue 10 years ago • 5 comments

Will ParseReact support Parse count queries in the observe function?

See https://parse.com/docs/js/guide#queries-counting-objects

mikemintz avatar May 07 '15 17:05 mikemintz

Instead of using the count query I have been getting the length on the array of objects returned from the observe function.

observe: function() {
   return {
      comments: (new Parse.Query('Comment')).ascending('createdAt')
   }
}

render: function() {
   //get count of your return data
   console.log(this.data.comments.length);
  ...
}

agnosticdev avatar May 08 '15 01:05 agnosticdev

@mikemintz We've been trying to work out a decent way to expose this expanded functionality on ParseQuery. Most of the trouble is a matter of working out an ideal API. Ultimately, we need to generate a count Observable from a query, and also decide whether counts will be automatically updated by mutations. Once we have a decent proposal for the API, I think we should move forward with implementing just that bit, and we can treat local updates as improvements to be dealt with down the road.

andrewimm avatar May 08 '15 20:05 andrewimm

It would be great to support count so that higher level components don't have to query for entire objects.

Can we merge #88?

TylerBrock avatar Jul 16 '15 16:07 TylerBrock

Re: #88, @philikon and I were hoping to have a conversation around maintaining updated stores, but I think the consensus is that we will not dynamically update count queries for now. Hopefully we can land it in the next few days.

andrewimm avatar Jul 16 '15 16:07 andrewimm

I finally found the time to update #88 with the changes that @andrewimm and I talked about offline.

philikon avatar Aug 03 '15 20:08 philikon