when transmitting references other datastore entities using message class protorpc, should use str(key) or key.id(). first 1 string second 1 long.
does make difference in end? there restrictions?
it appears when filtering queries, same results come out.
thanks
it depends on goal , whether or not you're using db or nbd.
if use str(key) you'll entity key , need construct new key (on server depending on value). using ndb, recommend using key.urlsafe() explicit , ndb.key(urlsafe=value) create new key. unfortunately best can db str(key) , db.key(string_value).
using key.id() depends on ndb or db. if using db know value integer (and key.name() string) if using ndb either integer or string. in case, should use key.integer_id() or key.string_id(). in either case, if turn integers strings, require manually casting integer before retrieving entities or setting keys; e.g. mymodel.get_by_id(int(value))
if make recommendation, advise explicit ids, pay attention way allocated , give these opaque values user in api. if want let app engine allocate ids use protorpc.messages.integerfield represent these rather casting string.
also, please switch db ndb if haven't already.
Comments
Post a Comment