n1ql statement using cbc doesn’t accept variable from shell
shell parameters:
$bucket=mybucket
$7=docid
$3=environment
$4=myhost.com
$5=1234
cbc n1ql ‘update $bucket
USE KEYS “$7” set $3.host = “$4”, $3.port =’$5’ returning $bucket
.*’ -U $cb_url -P $pass
my goal is to be able to update existing documents through commandline from a remote server. any ideas how to achieve this?
I have not tried shell, but you can use rest api for CURD operation.
Write shell script which does curl operations
In addition to @nihar.rathod’s suggestion, you may want to look at invoking cbq
through the command line.
Or you might want to look at writing a simple program in Python, which can be invoked like a shell command.
avsej
4
btw shell does not interpolate single quotes
Thanks folks! i’ve written simple python for update and so far i was able to pass values from main shell script.
I should have made it clear what i meant by “update”. Last two functionality i am trying to achieve then i am done
- I would like to be able to add some attribute on an existing document
- edit an existing attribute
The values required on the “update” will be provided by user as parameter
my doc looks like this
{
“type”: “address”,
“DEV1”: {
“port”: “43000”,
“host”: “host1.bigip.com”
},
“PT2”: {
“port”: “42000”,
“host”: “host2.bigip.com”
},
“ST2”: {
“port”: “52000”,
“host”: “host3.bigip.com”
}
}