luisbg
luisbg

Reputation: 574

Compound Query JS SDK paRse.com

I have one class Messages with 3 principal fields:

id FromUser ToUser

I do have a query where the To = Value field and the From field is not repeated. I mean, get all FROMUSER who sent me a message.

Any Idea?

Thanks!

Upvotes: 0

Views: 243

Answers (1)

Luca Iaco
Luca Iaco

Reputation: 3457

As @Fosco says, "group by" or "select distinct" are not supported yet in Parse.com.

Moreover keep in mind the restriction on the selection limit (max 1000 results for query) and timeout request call ( 3 seconds in the before save events, 7/10 seconds in the custom functions ). For the "count" selection, the restriction is the timeout request call.

I'm working on Parse.com too, and i've changed a lot the structure of my db model, often adding some inconsistent columns in several classes, keeping them carefully updated for each necessary query.

For cases like yours, i suggest to make a custom function, that keep in input two parameter ( we can say, "myLimit" and "myOffset" ) for the lazy loading, then select the slices, and programmatically try to filter the resulting array item list (with a simple search using for..loop, or using some utility of UnderscoreJS). Start with small slices ( eg: 200-300 records maximum for selection ) until the last selection returns zero results ( end reached). You could count all items before start all of this, but the timeout limitation could cause you problems. If this not works as expected try to make the same, client side.

You could also make a different approach, so creating another table/class, and for each new message, adding the FromUser in that table ONLY if it doesn't already exist, for that specified ToUser.

Hope it helps

Upvotes: 0

Related Questions