Following is the sample document (userdetails) in couchbase.
{ "friends":[
{
"company":"microsoft",
"firstname":"criss",
"lastname":"angel"
},
{
"company":"google",
"firstname":"captain",
"lastname":null
} ] }
based on the company name, i want to remove the respective json document from the array.
n1ql query
update default use keys "userdetails" set friends=array_remove(friends,a) for a in friends when a.company="google" end returning friends
Im not able to remove the json data using the above query.
This query works properly, if we have empty string ( "lastname" : " ") rather than null value.
So, how to remove, if any of the parameter value is "null"