Couchbase文档ID生成 [英] Couchbase document id generation
问题描述
我有一个集成了ouchbase 6.0的Springboot应用程序. 我已经读过,如果一个键用@Id注释,那么它将被另存为文档ID,并且不会成为json的一部分.
I have an Springboot application integrated with couchbase 6.0. I have read that if a key is annotated with @Id then it will saved as an document id and will not be a part of the json.
然后我在键上一起使用了@Id和@Field,但该字段仍未出现在json文档中.
Then i have used @Id and @Field together on the key but still that field is not appearing on json document.
有人可以帮我解决以下问题吗?
Can somebody help me out on the following:
1:如何使用与文档ID相同的密钥,并将其保留为json的一部分.
1: How to make same key as document id and keep that a part of json also.
2:如果使用@Id声明字段,则将其创建为文档ID并执行 没有出现在文档中,但是当我执行获取请求时,相同的键出现在文档中 响应.
2: If a field is declared with @Id, it is created as document id and does not appear on document, but when i do a get request same key appear on the response.
I have also tried, click here https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration.usingattributes
我的实体是:
@Id @GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES,delimiter="::")
private String id;
@IdAttribute
private String userid;
@Field
private String fname;
@Field
private String lname;
发布方法正文:
{
"id": "888",
"userid":"user1",
"fname": "xyz",
"lname": "abc"
}
在Couchbase服务器中,该文档另存为
In Couchbase server, it is saving this document as
仅创建文档ID为 888 ,它应生成文档ID为 888 :: user1
It is creating document id as 888 only, it is supposed to generate documnet id as 888::user1
我已经测试了很多次,但是结果是一样的.
I have tested this many times but the result is same.