Hi Markus,

On Sun, Sep 20, 2009 at 10:01 PM, Markus <[email protected]> wrote:

>
> Hello,
>
> I have two db.Models let's call it Model A and Model B.
>
> Model B has an field "ref = db.ReferenceProperty(A)"
>
> Now I know a db.key from a database entry in A and want to find all
> database entries of B which referes to that specific entry in A.
>
> I tried a naive approach:
>
> # first get all entries from B
> datas = db.GqlQuery("SELECT * FROM B")
>
> #
> for B in data:
> #        if B.ref == familarKeyFromA:
>

B.ref is an Entity, not a key, so hence the comparison will always fail.


>              # found an entry in B who referes to A
>              ...
>
> But this doesn't work. I get no results. But i know that there exists
> entries in B with a reference to an entry in A (familarKeyFromA).
>
> Probably the simple "if B.ref == familarKeyFromA" doesn't work. But
> how can I compare to db.key's?
>

You can simply query for entities whose keys match: db.GqlQuery("SELECT *
FROM B WHERE ref = :1", somekey).

-Nick Johnson

>
> Thanks a lot!
> >
>


-- 
Nick Johnson, Developer Programs Engineer, App Engine
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to