If you know an entity's id you can easily reconstruct the key without
a datastore hit. Try:
thekey = db.Key.from_path('MyKind',id_value)
id_value needs to be an integer if it is an id and not a key_name.
Then just filter and orderby __key__.
Robert
On Tue, Jan 5, 2010 at 7:58 PM, B. Suchland <[email protected]> wrote:
> I was wondering if anyone knew if it is possible, given the id of a
> specific database entry (eg 50), to fetch all entries from the same
> database model with a higher id (In this case anything above 50) using
> only a single database hit.
>
> In other words, is there any way to do the equivalent of this invalid
> query:
>
> SampleModel.gql('WHERE id > 50')
>
> I have seen solutions where the id of an entry is stored as a separate
> string property as follows, but this requires two database writes and
> leaves a small window of time in between the two where the id field is
> empty:
>
> sm = SampleModel()
> sm.put()
> sm.id = sm.key().id()
> sm.put()
>
> I have also seen a proposed solution using get_by_id() with a list of
> ids starting at 50 as an argument, but I was hoping to find a solution
> that did not require me to be aware of the number of possible entries
> beyond the one with the id of 50.
>
> Any help would be greatly appreciated!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.