密钥与ID/名称?

编程入门 行业动态 更新时间:2024-10-26 08:26:42
本文介绍了密钥与ID/名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不想为我的实体创建自动生成的密钥,所以我指定自己的密钥:

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/名称?

本文发布于:2023-10-30 03:27:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541625.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密钥   名称   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!