Reputation: 17
My kind looks like this:
class userScore(db.Model):
# stores info about each users' score
created = db.DateTimeProperty(auto_now_add = True)
username = db.StringProperty(required=False)
score = db.StringProperty(required=False)
I retrieve a given user's score like this:
username = 'John'
userScore.all().filter('username = ', username).get()
This works well when each user has only one entity with one score. But what if I have multiple entities for the same user with different scores? E.g.
created username score
1/30/16 John 100
1/31/16 John 99
1/28/16 John 101
Question:
Will .get() always return the most recent result, i.e., 1/31/16 John 99?
I have been reading about model.get() but I can't figure it out.
Update/details
According to the documentation, .get() "executes the query and returns the first result, or None if no results are found". What I am trying to understand is what first means exactly. Thank you to Dan Cornilescu for helping me clarify what I am actually asking about.
Thanks for help.
Upvotes: 0
Views: 54
Reputation: 39814
The .get()
you have in your code is not a model.get()
, which is likely what throws you off.
The userScore.all()
is a Model.all()
, which returns a Query
, so your .get()
is actually a Query.get()
which will return a list of matching results that can be sorted/ordered if you so desire, using Query.order()
.
Upvotes: 1