How to upload primary key as an id instead of name - Google App Engine for Java | Googl... - 0 views
-
If you use the RemoteDatastore you have complete control in Java of what you key is. http://code.google.com/p/remote-datastore/ e.g. this code puts an entity with the id set in your remote datastore from your local machine: RemoteDatastore.install(); RemoteDatastore.divert("http://myVersion.latest.myApp.appspot.com/remote-datastore ", "myApp", "myVersion"); DatastoreService service = DatastoreServiceFactory.getDatastoreService(); Key key = KeyFactory.createKey("MyKindName, 35); Entity entity1 = new Entity(key); entity1.setProperty("property1", "hello"); datastore.put(Arrays.asList(entity1, entity2);
-
You can do this now using the RemoteDatastore Java utility http://code.google.com/p/remote-datastore/ For example, this code runs on your desktop and creates a single entity in your live datastore: // divert datastore operations to live application RemoteDatastore.install(); RemoteDatastore.divert("http://myVersion.latest.myApp.appspot.com/remote-datastore ", "myApp", "myVersion"); // create an entity with a numeric key Key key = KeyFactory.createKey("MyKindName, 35); Entity entity1 = new Entity(key); entity1.setProperty("property1", "hello"); // put entity to the remote datastore DatastoreService service = DatastoreServiceFactory.getDatastoreService(); datastore.put(entity1); This also works for bulk puts
-
this won't be available until 1.3.6. You should be able to do something like this: - property: __key__ external_name: CityId export_transform: datastore.Key.id import_transform: lambda value: datastore.Key.from_path('City', int(value))