Select & delete array

I want to run a query in the Employee bucket, to delete an array object, where EmployeeBranch.EmployeeBranchId is same value. How can I achieve this? I’m new to couchbase. Thanks!

JSON is like this:

{
  "EmployeeBranch": [    
    {     
        "Branch": "California",      
        "EmployeeBranchId": 1    
    },
    {      
        "Branch": "Oregon",      
        "EmployeeBranchId": 1    
    },
    {      
        "Branch": "New York",      
        "EmployeeBranchId": 2    
    }
  ],  
  "EmployeeInformation": [    
    {      
        "Branch": "California",      
        "Status": "active",      
        "EmployeeBranchId": 1    
    },    
    {      
        "Branch": "Oregon",      
        "Status": "inactive",      
        "EmployeeBranchId": 1   
    },    
    {      
        "Branch": "New York",      
        "Status": "active",        
        "EmployeeBranchId": 2    
    }
],  
    "EmployeeId": 1212
}

Desired result:

{  
  "EmployeeBranch": 
    [    
    {      
        "Branch": "California",      
        "EmployeeBranchId": 1    
    },
    {      
        "Branch": "New York",      
        "EmployeeBranchId": 2    
    }
  ],  
  "EmployeeInformation": 
  [    
    {      
        "Branch": "California",     
        "Status": "active",      
        "EmployeeBranchId": 1    
    },    
    {      
        "Branch": "Oregon",      
        "Status": "inactive",      
        "EmployeeBranchId": 1   
    },    
    {      
        "Branch": "New York",      
        "Status": "active",      
        "EmployeeBranchId": 2    
    }
  ],  
  "EmployeeId": 1212
}

EmployeeBranchId = 1 has two entries which one do u want retain?

SELECT d.*,
          (SELECT RAW MIN(eb)
           FROM d.EmployeeBranch AS eb
           GROUP BY eb.EmployeeBranchId) AS EmployeeBranch
FROM default AS d
WHERE ......;

I want to retain the 1st entry (branch California) and delete the 2nd entry (Branch Oregon). Thanks!