Hey guys,
I am using BaasBox, a 'Back-end as a service' for mobile applications. It
is using OrientDB as its database. I love it, there are so many benefits.
Currently, I am developing a game, in which users can earn points. We need
a highscore. I'm trying to query the DB to determine...
- top players,
- worst players,
- current user's ranking
"Players" are objects, that match the following scheme:
{
points: 123,
username: 'pete'
}
What I need, is some kind of a field, that acts as the '*ranking*' of each
of the users. The ranking should be the number of the row in the ordered
query ('*ORDER BY points DESC*'). Note that this is not the id of the
object, since it's dynamic and can change over time depending how many
points the user has earned.
BaasBox currently (v0.9.2) does not allow querying arbitrary queries
("SELECT ..."), but provides a simplified interface:
BaasBox.Documents.find({
fields: 'username,points',
orderBy: 'points DESC',
page: 0,
recordsPerPage: 3 // Get the best three players
},'User');
Questions:
1) Is there a certain OrientDB function / method, that returns the row
number? I've been searching for row_numer(), etc., but couldn't find any in
the specs.
2) How will I determine the current user's ranking? I assume I will have to
scan the entire user database and return the row_numer() once the user has
been found. How would that look like in OrientDB?
With this constrained API in mind, is
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.