ON CASCADE statements

Hi, I have a particular use case where I have two types of documents, let’s call the first A and the second B, that have a one to many relationship as follows:

A: {
references: [“b_id1”, “b_id2”…]
}
B: {

}

Obviously ‘references’ array contains the list of the ids of related B items.
When I create a document B referenced to a document A I want his id to be added to the references array, and when I’ll delete it, I want it to be removed.
How can I do this without sending two different requests to the server (one for creation/deletion, handled by Couchbase for NodeJS SDK, and one for array handling on ‘references’)? I’m worried because If I send these two statements and one of them fails, I’ll have a consistency lack in my dataset.

Is there any way to reproduce ‘ON CASCADE’ statements of foreign keys of SQL?

Hi,
so to ask the question another way, does Couchbase support transaction? Right now it does not.
So to make sure you don’t have consistency issues you would need to make some consistency checks, or some log reconciliation(like most of the highly distributed banking system do).

Can you manage with just having each B document reference its parent A document? If you need the array in A, then unfortunately, as Laurent said, you need to maintain that array for now.

For consistency, you could remove the B reference from the array before deleting B.