I have just realised, all the curl commands being mentioned are able to be executed in the browser.
I can not seem to work out what is the correct command to get the output from a view.
My database is on iriscouch.
http://mysite.iriscouch.com/mydb/_design/myview
lists the view, but how do I run the view so that the records are displayed ?
Thanks - mcl
You need to insert _view into the url:
http://mysite.iriscouch.com/mydb/_design/mydesign/_view/myview
Related
Description:
Implement a ZoomingAndScrolling chart with infinite scrolling capability.
Set up a new project on CodeSandbox, using the template from the following link
https://js.devexpress.com/Demos/WidgetsGallery/Demo/Charts/ZoomingAndScrolling/React/Light/
populate the chart by retrieving the data from the "trips" table using HTTP rest API from https://demo.questdb.io/. x should be "pickup_datetime" and y should be "trip_distance"
https://questdb.io/docs/develop/query-data/#http-rest-api
provide infinite scroll functionality for the graph chart; the concept of infinite refers to the ability to dynamically load new data as needed than loading all the data at once. Reference:
https://js.devexpress.com/Demos/WidgetsGallery/Demo/Charts/LoadDataOnDemand/React/Light/
Once you complete the task, please share the CodeSandbox link.
Not able to go ahead before fetching data from that table in questDB.
I get this is an exercise about React, but I can help with the QuestDB side of things, which is blocking you :)
To get data from QuestDB in your example you should use the exec endpoint of the REST API.
Note that in the demo machine, the exec port is directly the 443 port, so you could execute this call to get the first 100 results
curl -G \
--data-urlencode "query=SELECT pickup_datetime, trip_distance from trips;" \
--data-urlencode "limit=1,100" \
https://demo.questdb.io/exec
As you can see, you can just issue queries changing the limit (next one would be from 101 to 200) until you get no results. You can choose a limit as high as you want for every page of data, so you probably want to adjust for how much data you want to display at once. Please be advised the demo is limited to 1000000 results per page.
If you want to see some javascript to help you, you can see an example at https://questdb.io/docs/develop/query-data/#querying-data. Please note you would need to add the http limit parameter for pagination
I'm trying to use the github REST api to get pull requests by user. I've read the docs and looked for examples and can't find clear directions how to do this. The basic .../pulls url works just fine - I get back a big list of pull requests. But when I try to filter to a user the way the docs seem to say, I just back an empty array.
I have verified:
The user names I am trying are correct- I have copied them from the pulls.user.login field
The users I am trying have pulls that show up in the .../pulls output
Here is what I have tried:
These attempts always return an empty array:
[githost]/api/v3/repos/[owner]/[reponame]/pulls?head=user:myusername
[githost]/api/v3/repos/[owner]/[reponame]/pulls?head=user:myusername&state=all
[githost]/api/v3/repos/[owner]/[reponame]/pulls?head=user:myuserid
[githost]/api/v3/repos/[owner]/[reponame]/pulls?head=user:myusername#mydomain
These desperate attempts always return the same output as .../pulls with no parameters
[githost]/api/v3/repos/[owner]/[reponame]/pulls?head=myusername
[githost]/api/v3/repos/[owner]/[reponame]/pulls?user=myusername
So what is the correct way to do this?
According to the GitHub,
Every pull request is an issue, but not every issue is a pull request.
So try this to get the list of all PRs created by a specific user:
https://api.github.com/search/issues?q=author%3Agenialkartik+type%3Apr
Don't forget to replace my username 'genialkartik' with your username.
OK, I figured it out by using git's search api.
The query I used looks like this:
[githost]/api/v3/search/issues?per_page=50&q=type:pr+author:myusername
The results are little more terse than what .../pulls gives, but that's something I can work around.
I see one strange thing happening to CouchDb. When I go Futon page I see that I need to login. Otherwise, I will get an error message Error: anathorized if I try to change some view function. And when I login, this error goes away. So, this seems ok.
What is not ok is that when I try to invoke some view with curl without providing user and password, I do not get any error message, but get some result. I do it like this:
curl -XGET 'http://127.0.0.1:5984/db/_design/query/_view/delete/?key="object_1_"'
This view ^^^ is supposed to return a long list of data. In fact, 26 rows. And this is what I see in Futon when I'm logged in. But here as a result of curl command I get:
{"total_rows":26,"offset":25,"rows":[{"id":"...","key":"object_1_","value":"..."}]}
So, as you can see I get one row of data. I have several questions. Why does CouchDb enable to query itself without providing user and password, when they are required? And why does it return so strange result - total_rows = 26, but in fact there is only one single row.
PS. Ubuntu 15.04, CouchDb 1.6.0
EDIT
If I provide user and password like this:
curl 'http://user:password#....similar'
then I still get this strange result with one row of data.
You did not restrict the database to any admins, admin_roles, users or user_roles - so ANYBODY has access to that database. This is DEFAULT and stated in the documentationen.
Why your view does return "strange results" does depend on your view and query.
I have zii.widgets.grid.cgridview on admin page, and when I search some records and visit view one of them, and after return to admin page results is reseted. May I save them someway?
As a suggestion:
First disable Ajax update in your CGridView's view:
'ajaxUpdate' => false
Now, it sends data via GET request. If you save the current GET, it would be possible to use the result later. It is accessible with:
$_GET['YOUR_MODEL_NAME'];
If you want to use it in somewhere else, you can get values from GET and put it into a CDBCriteria.
Others might offer another way.
I am putting a document into couchdb like this:
curl -X PUT http://localhost:5984/bucket/keyname_1 \
-d '{"foo":"bar"}'
This works just fine as long as the document doesn't already exist. If it does exist, I need to include a "_rev" key to validate that I am updating an existing document:
curl -X PUT http://localhost:5984/bucket/keyname_1 \
-d '{"_rev":"2-207df9da","foo":"bar"}'
If the _rev key is missing, or if the _rev key is doesn't match what's in the existing record, this throws a "conflict" error. This is how you know that a revision isn't being thrown away.
But what if I want to write it unconditionally, and bypass this check?
I have a design where I am updating the main record, with the check, and then I want to save a brief summary record with only a couple fields that can be easily grabbed and downloaded for a summary screen. Since I just updated the main record, I know that I have the latest copy. I just want to do a write, and I don't want to have to do a read first just to get the _rev. This would be redundant.
Is there any way that I can modify my request to tell couchbase to skip the _rev check and just put the document in unconditionally?
So you have two documents that you want to update: main and summary. Even if you have the latest version of main, will that actually mean you have the latest version of summary as well or do you just want force the last no matter what? If, then you might have a look at Update handlers: http://wiki.apache.org/couchdb/Document_Update_Handlers
Also, if you go with some kind of secondary GET to fetch the latest _rev, use a cheaper HEAD request.
EDIT: BTW, why having two separate documents? Is the Summary one in fully complete with the Main one? All all the members found there? Could you then perhaps use Show or list functions? http://wiki.apache.org/couchdb/Formatting_with_Show_and_List
Instead of PUTting the record, why not POST a new one?
That way, you keep a full record of all such log events, but you don't have to deal with document conflicts.