0
votes

I have data like this in my Couchbase:

{
“mappings”: {
“/”: “Ana sayfa”
},
“platform”: “WEB”
}

I want to convert all data like this:

{
“/”: {“viewLabel”:“Ana Sayfa”}
“platform”: “WEB”
}

So I want to share old version:

{
“_class”: “com.commencis.appconnect.adminpanel.data.entity.ScreenNamesMappingEntity”,
“id”: “whitelabel::WEB::screenNamesMapping”,
“mappings”: {
“/”: “Ana sayfa”,
}
}

I want to create new document with above id:

 ( “id”: “whitelabel::WEB::screenNamesMapping”) 

and delete the old one.

I want to create and convert like this:

{
“_class”: “com.commencis.appconnect.adminpanel.data.entity.ScreenNamesMappingEntity”,
“id”: “whitelabel::WEB::screenNamesMapping”,
“mappings”: {
“/”: { “viewLabel”: “Ana sayfa” } ,
}

I need to write script. I want to create new document with related id, then delete the old one, it could be multipe N1QL

I should not update the old data, new data should have new key, and I should edit the new key with the old one and delete the old one. I need to do with that way.

1
Could you please reformat your code and question? I can't clearly understand what you are trying to accomplish. - deniswsrosa

1 Answers

2
votes

You can use the same document id by overwriting the current document, but there should be two repositories for both the entities.

oldRepository.findById("myid").ifPresent(e -> {
 NewEntity ne = new NewEntity(e.id(), e.platform()...);
 newRepository.save(ne); });