I'm trying to update a single field in my document using BlueMix Cloudant Nosql. The problem I'm facing is that I'm just overriding the whole document and not updating the single item or list of items. What is the proper way to execute the HTTP PUT command to do this? I'm new to both JSON and Nosql.
{
"_id": "2c314478997815d6e4037c0b1a848678",
"_rev": "10-a965f79ad26a23796cd331e6b1a04378",
"organization": "BusinessName",
"email": "emailaddress"
}
curl -X PUT -H "Content-Type: application/json" HTTP1.1 '<Address>/<db>/<document> -d '{
"organization": "New Data",
"_rev": "<rev_id>"}'
Cloudant is based on the Apache-backed CouchDB project and the open source BigCouch project.
You can not do partial updates in CouchDB. Get the document, update locally and push the whole doc back using PUT and the right _rev
Related
I'm trying to use a proper schema for keys too. By default, it is created as:
{"subject":"AVROTEST-key","version":1,"id":60,"schema":"\"string\""}
But I want it like:
{"subject":"AVROTEST-key","version":1,"id":60,"schema": "{\"type\":\"record\",\"name\":\"AVROTEST\",\"fields\":[{\"name\":\"key\",\"type\":\"long\"}]}"}
Because of the compatibility issues, I tried to delete it completely and add a new one. I've deleted it using
curl -X DELETE http://XXXXXX.XXXXXX:1234/subjects/AVROTEST-key/versions/1
there are no other versions and I get a 404 error when I try to GET it after deleting, which means it's deleted successfully. But when I try to register a new schema, I get this error:
"error_code":409,"message":"Schema being registered is incompatible
with an earlier schema"
How can it be incompatible with an earlier schema, while there is no schema? What am I missing?
This is how I register a new schema:
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{\"type\":\"record\",\"name\":\"AVROTEST\",\"fields\":[{\"name\":XXXXXX.XXXXXXXX:1234/subjects/AVROTEST-key/versions
Looks like there was another schema version which I didn't know about it. A funny mistake actually, I should've deleted all the versions, instead of [1]. So entering the command
curl -X DELETE http://XXXXXX.XXXXXX:1234/subjects/AVROTEST-key/versions/
solved my problem. All the previous schemas are deleted. But notice the new schema will not be registered as version [1]. It will increase the latest schema id.
I'm brand new to Grafana. Can I (and how) load a JSON into Grafana and display as a table? Or is it only for time series data?
I'm loading grafana with:
docker run -d \
-p 3000:3000 \
--name=grafana \
-e "GF_INSTALL_PLUGINS=grafana-simple-json-datasource" \
grafana/grafana
For example:
[{
"hostname": "1.2.3.4"
}, {
"hostname": "2.3.4.5"
}, {
"hostname": "3.4.5.6"
}]
Display that as:
hostname
1.2.3.4
2.3.4.5
3.4.5.6
If I can achieve that (which is the scope of this post),ultimately I want to load 2x tables in and diff them to show a third (calculated) table which includes the items in table 1 but NOT table 2.
For example, if table 2 is:
hostname
2.3.4.5
3.4.5.6
Then table 3 would be:
hostname
1.2.3.4
Grafana is just a visualisation tool. It needs a data source to query data and display. It is optimised for time series data, but static data can also be displayed easily.
Use the API plugin .
You can also use TestData DB data source which is available within Grafana to test scenarios. (does not use json though)
Once the data source is configured, you can use table panel to display data based on queries.
Each dashboard can have multiple panels so tables can be shown side by side.
I am trying to run schema to a schema registry by explicit curl command.
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema" : {"type":"record","name":"myrecord","fields":[{"name":"f1","type":"string"}]}' http://localhost:8081/subjects/avro-test/versions/
I am getting the below error
{"error_code":500,"message":"Internal Server Error"}
Note : I am able to access the data from the existing subject but getting the same error while pushing it.
The schema needs to be string escaped
For example, starting out
POST -d'{"schema": {\"type\":\"record\"
If you can, then installing jq tool and create an AVSC file instead, that would help - see my comment here
I am trying to deploy my feathersJS app on heroku with mongodb database. I used mLab sandbox plan, I did not configure anything on it. But as there is no documentation or any previous questions about it here I am.
I have made a feathersJS app running with mongodb. But when I deploy it on heroku I always get an error 503, service unavaible (timeout).
Here is in /config/default.json
"mongodb": "mongodb://localhost:27017/api_feathers",
There is may be something to change on this line.
And here production.js
{ "host": "api-feathers-app.feathersjs.com", "port": "PORT" }
As already pointed out you can add the MongoDB URL to your production.json in the mongodb property. Heroku will also set the MONGODB_URI for most MongoDB addons which you can use by changing production.json to::
{
"host": "api-feathers-app.feathersjs.com",
"port": "PORT",
"mongodb": "MONGODB_URI"
}
If you log into mlab and go to your database you should see a connection string. At the bottom of your production.json you should add a line to connect to the mlab database.
Something like:
{
"host": "api-feathers-app.feathersjs.com",
"port": "PORT",
"mongodb": "mongodb://USERNAME:PASSWORD#ADDRESS-AT-MLAB:PORT/DB_NAME"
}
That last line will be provided to you in the mlab settings. In addition mlab may require some query string at the end of the mongodb url, such as ?ssl=true. But they will tell you what is necessary.
Log in to your mlab account and create a new environment if not created already.
Then click on the database name. It will show you tab containing Collections, Users, Stats, Backups and Tools.
Click on the Users tab and it will show you a list of users assigned to that db. If you haven't created a user for that, then you will have to create a user by clicking on the "Add database user" button.
Once the user has been created you then add this to your production.json file. Add this as the value to the mongodb key in production.json file
mongodb://<dbuser>:<dbpassword>#ds115749.mlab.com:15749/<dbname>
replace the <dbuser> with the database username you created earlier and <dbpassword> the password associated to the dbuser and replace with the name of the database you are trying to access.
Here's a full code base for the production.json file
{
"host": "https://your.domainname.com/",
"port": "PORT",
"public": "../public/",
"paginate": {
"default": 10,
"max": 1000
},
"mongodb": "mongodb://<dbuser>:<dbpassword>#ds115749.mlab.com:15749/<dbname>",
}
Please note, default.json is for your development environment while production.json is for your production and used when you are deploying file in the same directory.
I created an instance of IBM Graph service on bluemix and created some vertexes. When I try to issue a gremlin query to find one of the vertexes I created, I get an "Internal Error".
Here's the query I'm using
Create the Vertex
curl -u username-password -H 'Content-Type: application/json' -d '{ "label":"movie","properties":{"Name": "Million Dollar Baby","Type": "Movie"} }' -X POST "http://../g/vertices"
Reponse
{"requestId":"07f29cea-25b3-4305-b74b-540466206872","status":{"message":"","code":200,"attributes":{}},"result":{"data":[{"id":8336,"label":"movie","type":"vertex","properties":{"Type":[{"id":"36a-6fk-1l1","value":"Movie"}],"Name":[{"id":"2s2-6fk-sl","value":"Million Dollar Baby"}]}}],"meta":{}}}
Query whether the vertex has a Type property 'movie'
curl -u username-password -H 'Content-Type: application/json' -d '{"gremlin": "def g = graph.traversal(); g.V().has('Type','movie')"}' -X POST "http://../g/gremlin"
Response (Error)
{"code":"InternalError","message":""}
IBM Graph requires users to create indexes for any property that they are going to issue queries against. In this case 'Type' is a property and is included in a gremlin query.
You need to create an index using the /schema endpoint which is provided by the IBM Graph service in bluemix.
An example of this is provided in the Service Getting Started guide
http://ibm-graph-docs.ng.bluemix.net/gettingstarted.html