hi,
i have below 2 documents
employee:
{
empid:1
name:“Adam”,
age:35
}
department:
{
depid: 1,
depname: CSE
}
Need to update employee to add department but also need to ensure the department being added is part of department document . How to perform this update in spring data couchbase? pls guide
mreiche
November 16, 2022, 9:45pm
2
Need to update employee to add department
Can you show what the updated employee would look like? Do you mean by adding just depid? Or the whole department?
the department being added is part of department document
I’m not certain what that means. Are you looking for the equivalent of a foreign-key constraint?
Hi Mreiche,
Updated employee would look like as below
employee:
{
empid:1
name:“Adam”,
age:35,
depid: 1
}
the department being added to employee document should be part of department document else we need to reject the update
Assuming we have only depid 1 in department document the below update should fail
employee:
{
empid:1
name:“Adam”,
age:35,
depid: 2
}
There is no mechanism to enforce foreign-key constraints