java - Receive entity by newest created first on Google App Engine -


i'm using android , built project google app engine. when receive list of entities come me first created. need them come in opposite direction, or 100 newest. can put limit on how many receive actually. cannot find on google or stackoverflow. has questions or examples on this. quick help?

you want commit dateproperty field index=true , auto_now_add=true. can sort descending on field fetch limit. there may slicker ways, tried , true.

imho - idea include date_created property on every important entity. whether or not index depends on use. noted tomasz, entity ids - while ascending - not guaranteed so. not rely on them. if ever find needing progress sequentially though model, happy have "datec" field. (also idea include "version" integerproperty on every record proves useful whenever need read/write way through existing entities ensure recent property change applied them all.) given these potential benefits, ask costs keep ending each model these 2 properties. {note: indexing real cost, not set index=true these fields unless plan use it.)

datec = ndb.datetimeproperty(indexed=true, auto_now_add=true) v = ndb.integerproperty(indexed=false, default=1) 
share|improve answer
    
no way row id in consecutive order? don't have db defined? google app engine have models , endpoint classes. that's why i'm having trouble finding example on how use cursor – nightskycode jul 22 '13 @ 15:48
1  
ids not monotonically increasing values. wishes were, not. many, many questions , threads spent covering on years. unfortunately, before knowing this, can conclude otherwise examining ids during development , testing since increase monotonically. – stevep jul 22 '13 @ 17:58

you can add order id desc , limit query

share|improve answer
    
that's thing.. noticed can use cursor query in every example i've looked database in app. google app engine database isn't in app endpoint , model classes.. i'm not sure how query – nightskycode jul 22 '13 @ 6:02
1  
i not think correct, far auto id policy goes. entity ids assigned datastore aren't consecutive. – tomasz Łazarowicz jul 22 '13 @ 8:37

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments