我不想为我的实体创建自动生成的密钥,所以我指定自己的密钥:
I do not want to create an autogenerated key for my entities so I specify my own:
Entity employee = Entity.newBuilder().setKey(makeKey("Employee", "bobby")) .addProperty(makeProperty("fname", makeValue("fname").setIndexed(false))) .addProperty(makeProperty("lname", makeValue("lname").setIndexed(false))) .build(); CommitRequest request = CommitRequest.newBuilder() .setMode(CommitRequest.Mode.NON_TRANSACTIONAL) .setMutation(Mutation.newBuilder().addInsert(employee)) .build(); datastoremit(request);当我查看该实体的外观时,它看起来像这样:
When I check to see what the entity looks like it looks like this:
如果我指定了自己的密钥(鲍比),为什么会生成此自动生成的密钥?似乎还创建了bobby,但是现在我有了bobby和此自动生成的密钥.密钥和ID/名称有什么区别?
Why is this auto-generated key generated if I specified my own key (bobby)? It seems bobby was also created, but now I have bobby and this autogenerated key. What is the difference between the key and id/name?
推荐答案这是密钥的url安全版本,适用于链接.使用 KeyFactory.stringToKey 转换为实际的密钥,您会看到它包含您的字符串名称.
This is the url-safe version of your key, suitable for use in links. Use KeyFactory.stringToKey to convert it to an actual key, and you'll see that it contains your string name.
更多推荐
密钥与ID/名称?
发布评论