My question must be so basic but any help is appreciated
I have a object like below
{
"type":"type_value",
"fruits" :[{"amt": 5},{"amt": 10}],
"shops" : [{"location": "X"},{"location": "Y"}]
}
I am using Spring WebFlux and couchbase. Couchbase supports collections and I am looking to store above object in 3 collections. the array of fruits/shops can contain any number of elements.
Couchbase has 'insert' function which returns Mono on one insertion. e.g.
Step 1:
Mono<TransactionGetResult> insertResult = ctx.insert(reactiveCollectio, id, objectToPersist)
I can only insert next element on 'insertResult' object. like below Step 2:
Mono<TransactionGetResult> insertResult = insertResult.then(ctx.insert(reactiveCollectio, id, objectToPersist));
again now if I want to insert next element I have to follow same as step 2 and keep doing until I am done then only I can commit the transaction.
using reactor api's how can I iterate and and within same how to use previous result ( Mono<TransactionGetResult> insertResult
) to perform my insertion?