in db, i set such a property in model article:

 auth = db.ReferenceProperty( author, collection_name="AuthSet" )


and use author.AuthSet to get all articles written by the certain author. 
there is no query. how can i do the same thing in ndb?


在 2014年7月22日星期二UTC+8上午3时55分28秒,Jay写道:
>
> Responding to your first post ... that is right. The parent key is part of 
> the entity's key. When you use get_by_id, this is just shorthand for 
> Key('Foo', 99).get().
> You cannot get an entity by key unless you know the key, the whole key. 
>
> You say you don't want to query, but your use case ... "give me all 
> articles for user A" ... sounds like a query. 
> articles = Article.query(Article.author == user_key)...
>
> If you want to do something like "most recent n articles" then you can 
> store those keys in a 'secondary index' of sorts and use ndb.get_multi()
>
> On Monday, July 21, 2014 8:11:20 AM UTC-5, saintthor wrote:
>>
>> to query may cost too many ops. i don't query.
>>
>>
>>
>> 在 2014年7月21日星期一UTC+8下午8时53分29秒,Kaan Soral写道:
>>>
>>> Not associated with google, also not an expert on ndb
>>>
>>> As far as I know key groups are related with consistency, in my opinion, 
>>> you shouldn't put article's and author's in the same group, there is a 1/s 
>>> write speed limit on entity groups, if you put them in the same entity 
>>> group, you could hit this limit more easily
>>>
>>> You don't even have to use referenceproperty's - I would just put the 
>>> author key in an article StringProperty named "author" and query for it, if 
>>> I were you
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to