google-cloud-datastore

Assigning an author to an entity during its creation

烈酒焚心 提交于 2019-12-11 13:34:38
问题 I am doing Udacity's Web Dev Course with Google Appengine and Python. I would like to know how I could assign to a created entity, its own author . For example, I have two ndb.Models kinds: class User(ndb.Model): username = ndb.StringProperty(required = True) bio = ndb.TextProperty(required = True) password = ndb.StringProperty(required = True) email = ndb.StringProperty() created = ndb.DateTimeProperty(auto_now_add = True) class Blog(ndb.Model): title = ndb.StringProperty(required = True)

Can the local development server be used to only simulate Cloud Datastore?

那年仲夏 提交于 2019-12-11 13:15:34
问题 If I'm developing an application that will run on the google container engine, but still wish for it to use cloud datastore, do I have any options to simulate cloud datastore for local development? Please note for the sake of correctly understanding my question: My application will not be Python, PHP or Java. It will not be running via App Engine, but via Container Engine. 回答1: Have you tried using cloud datastore's local development server? It sounds like exactly what you are looking for. 来源

How would I retrieve an Embedded Entity with repeated properties using datastore java client

故事扮演 提交于 2019-12-11 12:31:25
问题 I created entities on datastore using the AppEngine SDK's python APIs and I'd like to retrieve them on Google Cloud Dataflow (Java). The entity's structure is something like this: entity embedded_entity (ndb.StructuredProperty(repeated=True)) name name name name Retrieving would be something like this, but I know I am missing the step where I extract the data. static class EmbeddedStringExtractor extends DoFn<Entity, String> { @Override public void processElement(ProcessContext c) { Map

modelling in google-datastore: use lists or separate entities?

混江龙づ霸主 提交于 2019-12-11 12:29:23
问题 I'm stuck trying to implement a data model for an app to be deployed on AppEngine. Here's an example of the model: EntityName id: 1 author: 'me' description: 'whatever' datetime: 2011 etc. events: [ {location: [1,2], phase: ['A', 'B']}, {location: [3,4], phase: ['C', 'B']}, ... more events ... ] Explanation: EntityName has a few attributes, and many events each event has a list of numbers (its location ) and a list of strings ( phase ) How can this model be implemented in AppEngine? The data

How to create large number of entities in Cloud Datastore

[亡魂溺海] 提交于 2019-12-11 11:53:41
问题 My requirement is to create large number of entities in Google Cloud Datastore. I have csv files and in combine number of entities can be around 50k. I tried following: 1. Read a csv file line by line and create entity in the datstore. Issues: It works well but it timed out and cannot create all the entities in one go. 2. Uploaded all files in Blobstore and red them to datastore Issues: I tried Mapper function to read csv files uploaded in Blobstore and create Entities in datastore. Issues i

composite key in google cloud datastore

删除回忆录丶 提交于 2019-12-11 11:50:49
问题 In GCP Datastore & I've a kind with 3 properties. key (auto-generated) externalId externalName I can't allow duplicate externalName + externalId combination. Is it possible to maintain this uniqueness? 回答1: Options: Do what Robert said in his answer, although you would want to using the concatenation of externalId & externalName as the key. The only downside of this is if externalId or externalName change, then you wouldn't be able to change your key. You'd have to delete the current object

How to put/get multiple entities at once in Google cloud Datastore using java

℡╲_俬逩灬. 提交于 2019-12-11 11:19:10
问题 In the documentation, I didn't find how I can put or retrieve multiple entities at once. further, by using GQL, I was not able to execute queries such select * from k where __ key __ in ('key1','key2','key3'). Can any one help me please, how I can insert/ retrieve multiple entities at once using java?? Thanks, 回答1: In Cloud Datastore, a LookupRequest and CommitRequest allow multiple keys and entities, respectively, to be specified. For example: LookupRequest request = LookupRequest.newBuilder

GAE Arabic Support

廉价感情. 提交于 2019-12-11 10:44:30
问题 using this code i persist data to GAE Store but when storing Arabic it's format in Store become ????? how to support persist Arabic Text in GAE ? the code : PersistenceManager manager = PMF.get().getPersistenceManager(); Category category = new Category(categoryName); manager.makePersistent(category); manager.refresh(category); manager.close(); 回答1: It's more likely that the text is corrupted when you submit it from a form, or render it to HTML, rather than when it is stored (or retrieved).

Automatic ID for embedded entity

假如想象 提交于 2019-12-11 10:43:36
问题 Is there a way to let the datastore assign an automatic ID for an embedded entity? I use Mutation.Builder.addInsertAutoId and it works on "normal" entities, but I get an error when trying to generate an ID for an embedded entity: ApplicationError: 1: Entity is missing key. Example code Entity.Builder entity = Entity.newBuilder(); Key.Builder key = makeKey(m.getClass().getSimpleName()); entity.setKey(key); entity.addProperty(makeProperty("name", makeValue(m.getName()))); Entity.Builder

Wait for datastore update before proceeding

百般思念 提交于 2019-12-11 10:37:36
问题 I'm working on a lightweight app, and I have quite a few situations where the user submits a form, the form data is processed and pushed to the datastore, and then the user is redirected to a page that displays some of the same data. It's quite often the case that the user gets to the page before the datastore has been updated, so they see old data. Is there any way to have the app wait for the datastore to update before proceeding? The obvious hacky solution is calling sleep(1) , but that's