[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
thanks. 在 2014年7月26日星期六UTC+8上午9时02分35秒,Jay写道: I just deployed a little test app. It is under quota so I don't think appstats is reporting that for me. However, the important thing to note in this context is that whether I use the db api or ndb, it is the same datastore operation ... which is a query in this case. If you still need proof, I suggest you write your own test application. As Vinny suggested, you can post that and there might be some more discussion to come from it. On Friday, July 25, 2014 9:26:27 AM UTC-5, saintthor wrote: how many entities is in your db? how many ops cost for one call? 在 2014年7月25日星期五UTC+8上午8时03分44秒,Jay写道: I wrote a simple test app that used both the db and ndb api and deployed it to app engine. Using appstats I confirmed that both RunQuery when getting the list of articles. On Wednesday, July 23, 2014 8:03:40 PM UTC-5, Jay wrote: I refer you to line 3865 of __init__ in the ext.db package in the sdk. This is on a _ReverseReferenceProperty that gets setup. If I have time tomorrow I will write a quick test to demonstrate. On Wednesday, July 23, 2014 11:11:31 AM UTC-5, saintthor wrote: are you sure? i tested in two apps. the first is using query. when i do a query, the read ops increases about 300. the second is using referenceproperty as above, after 5 times showing, there is no obviously increase. the articles in the second app is much more than the first. so i don't think it run a query. 在 2014年7月22日星期二UTC+8下午11时20分14秒,Jay写道: When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
how many entities is in your db? how many ops cost for one call? 在 2014年7月25日星期五UTC+8上午8时03分44秒,Jay写道: I wrote a simple test app that used both the db and ndb api and deployed it to app engine. Using appstats I confirmed that both RunQuery when getting the list of articles. On Wednesday, July 23, 2014 8:03:40 PM UTC-5, Jay wrote: I refer you to line 3865 of __init__ in the ext.db package in the sdk. This is on a _ReverseReferenceProperty that gets setup. If I have time tomorrow I will write a quick test to demonstrate. On Wednesday, July 23, 2014 11:11:31 AM UTC-5, saintthor wrote: are you sure? i tested in two apps. the first is using query. when i do a query, the read ops increases about 300. the second is using referenceproperty as above, after 5 times showing, there is no obviously increase. the articles in the second app is much more than the first. so i don't think it run a query. 在 2014年7月22日星期二UTC+8下午11时20分14秒,Jay写道: When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
Re: [google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
On Fri, Jul 25, 2014 at 9:26 AM, saintthor saintt...@gmail.com wrote: how many entities is in your db? how many ops cost for one call? Perhaps you could post a test case application demonstrating what you're seeing and the size/content of your entities? It would make this conversation flow a bit easier. - -Vinny P Technology Media Consultant Chicago, IL App Engine Code Samples: http://www.learntogoogleit.com -- 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
I just deployed a little test app. It is under quota so I don't think appstats is reporting that for me. However, the important thing to note in this context is that whether I use the db api or ndb, it is the same datastore operation ... which is a query in this case. If you still need proof, I suggest you write your own test application. As Vinny suggested, you can post that and there might be some more discussion to come from it. On Friday, July 25, 2014 9:26:27 AM UTC-5, saintthor wrote: how many entities is in your db? how many ops cost for one call? 在 2014年7月25日星期五UTC+8上午8时03分44秒,Jay写道: I wrote a simple test app that used both the db and ndb api and deployed it to app engine. Using appstats I confirmed that both RunQuery when getting the list of articles. On Wednesday, July 23, 2014 8:03:40 PM UTC-5, Jay wrote: I refer you to line 3865 of __init__ in the ext.db package in the sdk. This is on a _ReverseReferenceProperty that gets setup. If I have time tomorrow I will write a quick test to demonstrate. On Wednesday, July 23, 2014 11:11:31 AM UTC-5, saintthor wrote: are you sure? i tested in two apps. the first is using query. when i do a query, the read ops increases about 300. the second is using referenceproperty as above, after 5 times showing, there is no obviously increase. the articles in the second app is much more than the first. so i don't think it run a query. 在 2014年7月22日星期二UTC+8下午11时20分14秒,Jay写道: When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
I wrote a simple test app that used both the db and ndb api and deployed it to app engine. Using appstats I confirmed that both RunQuery when getting the list of articles. On Wednesday, July 23, 2014 8:03:40 PM UTC-5, Jay wrote: I refer you to line 3865 of __init__ in the ext.db package in the sdk. This is on a _ReverseReferenceProperty that gets setup. If I have time tomorrow I will write a quick test to demonstrate. On Wednesday, July 23, 2014 11:11:31 AM UTC-5, saintthor wrote: are you sure? i tested in two apps. the first is using query. when i do a query, the read ops increases about 300. the second is using referenceproperty as above, after 5 times showing, there is no obviously increase. the articles in the second app is much more than the first. so i don't think it run a query. 在 2014年7月22日星期二UTC+8下午11时20分14秒,Jay写道: When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
are you sure? i tested in two apps. the first is using query. when i do a query, the read ops increases about 300. the second is using referenceproperty as above, after 5 times showing, there is no obviously increase. the articles in the second app is much more than the first. so i don't think it run a query. 在 2014年7月22日星期二UTC+8下午11时20分14秒,Jay写道: When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
I refer you to line 3865 of __init__ in the ext.db package in the sdk. This is on a _ReverseReferenceProperty that gets setup. If I have time tomorrow I will write a quick test to demonstrate. On Wednesday, July 23, 2014 11:11:31 AM UTC-5, saintthor wrote: are you sure? i tested in two apps. the first is using query. when i do a query, the read ops increases about 300. the second is using referenceproperty as above, after 5 times showing, there is no obviously increase. the articles in the second app is much more than the first. so i don't think it run a query. 在 2014年7月22日星期二UTC+8下午11时20分14秒,Jay写道: When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
When you use that api in db, it is doing a query underneath the covers. On Monday, July 21, 2014 11:27:08 PM UTC-5, saintthor wrote: 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
I am not a Google guy, but I think I can answer your question. key.parent does exactly what it says it does, gives the key of the parent of the key you have. So it is useful when you need that. An example might be if you have the key to a comment on an article (and you have set it up such that comments have the article as a parent) and you want to show all other articles by the author of the article on which the comment was made. Here is the bottom line when it comes to keys and queries in the context of your post. If you do not have the key(s) you are performing a query. How you get or know the keys is a different question. You may be able to construct the keys by knowing something about the context. You may have stored the keys someplace and have a pointer to them. You may have a key and need its parent ... etc. The db api and ndb api are the same in this regard. Specifically, the db api does not have some special way to get entities from the datastore without having the keys and also avoiding a query. You may not have realized that you were performing a query before in some circumstance, but you probably were. If it just a syntax thing you are after, you can always add some sort of getter method to your Article class to find all articles by a certain author - but it will use a query. On Monday, July 21, 2014 11:31:39 PM UTC-5, saintthor wrote: and, if you were a google guy, i'd like to ask what do you think the usage of key.parent is? in what instance it may be useful? 在 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
hi, are you a google guy? what do you think the real usage of the key group ( or tree ) is? for example, a forum, user entity and article entity, i set article.author to user entity, then how can i get all articles for a user? in db, i can set it with referenceproperty and get a _set ended property in user entity. in ndb, i have to use query to do this? 在 2014年7月21日星期一UTC+8上午3时02分27秒,Kaan Soral写道: I've also tested utilizing parent's recently, don't remember the exact reason I've found out that you can't get an entity only by id, if it has a parent, you have to know the parent too, that's why I utilized a different method to achieve whatever I was after at that time (don't remember) I also like to simply get entities by their id's - so I almost never give them parent's I would suggest not utilizing parent's unless you exactly know what you are doing I suspect you are learning ndb, I would suggest reading https://developers.google.com/appengine/docs/python/ndb*/ *fully AppEngine documentations are really easy to read and pretty fun, it shouldn't take 3 hours to grasp all concepts related to ndb -- 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
and, if you were a google guy, i'd like to ask what do you think the usage of key.parent is? in what instance it may be useful? 在 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.
[google-appengine] Re: ndb, get_by_id can not get an entity with a parent key only by id?
I've also tested utilizing parent's recently, don't remember the exact reason I've found out that you can't get an entity only by id, if it has a parent, you have to know the parent too, that's why I utilized a different method to achieve whatever I was after at that time (don't remember) I also like to simply get entities by their id's - so I almost never give them parent's I would suggest not utilizing parent's unless you exactly know what you are doing I suspect you are learning ndb, I would suggest reading https://developers.google.com/appengine/docs/python/ndb*/ *fully AppEngine documentations are really easy to read and pretty fun, it shouldn't take 3 hours to grasp all concepts related to ndb -- 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.