Note that there are some explanatory texts on larger screens.

plurals
  1. POCouchdb view Queries
    primarykey
    data
    text
    <p>Could you please help me in creating a view. Below is the requirement</p> <pre><code>select * from personaccount where name="srini" and user="pup" order by lastloggedin </code></pre> <p>I have to send name and user as input to the view and the data should be sorted by lastloggedin.</p> <p>Below is the view I have created but it is not working</p> <pre><code>{ "language": "javascript", "views": { "sortdatetimefunc": { "map": "function(doc) { emit({ lastloggedin: doc.lastloggedin, name: doc.name, user: doc.user },doc); }" } } } </code></pre> <p>And this the curl command iam using:</p> <pre><code>http://uta:password@localhost:5984/personaccount/_design/checkdatesorting/_view/sortdatetimefunc?key={\"name:srini\",\"user:pup\"} </code></pre> <p>My Questions are</p> <p>As sorting will be done on key and I want it on lastloggedin so I have given that also in emit function.</p> <p>But iam passing name and user only as parameters. Do we need to pass all the parameters which we give it in key?</p> <hr> <p>First of all I want to convey to you for the reply, I have done the same and iam getting errors. Please help</p> <p>Could you please try this on your PC, iam posting all the commands :</p> <pre><code>curl -X PUT http://uta:password@localhost:5984/person-data curl -X PUT http://uta:password@localhost:5984/person-data/srini -d '{"Name":"SRINI", "Idnum":"383896", "Format":"NTSC", "Studio":"Disney", "Year":"2009", "Rating":"PG", "lastTimeOfCall": "2012-02-08T19:44:37+0100"}' curl -X PUT http://uta:password@localhost:5984/person-data/raju -d '{"Name":"RAJU", "Idnum":"456787", "Format":"FAT", "Studio":"VFX", "Year":"2010", "Rating":"PG", "lastTimeOfCall": "2012-02-08T19:50:37+0100"}' curl -X PUT http://uta:password@localhost:5984/person-data/vihar -d '{"Name":"BALA", "Idnum":"567876", "Format":"FAT32", "Studio":"YELL", "Year":"2011", "Rating":"PG", "lastTimeOfCall": "2012-02-08T19:55:37+0100"}' </code></pre> <p>Here's the view as you said I created :</p> <pre><code>{ "_id": "_design/persondestwo", "_rev": "1-0d3b4857b8e6c9e47cc9af771c433571", "language": "javascript", "views": { "personviewtwo": { "map": "function (doc) {\u000a emit([ doc.Name, doc.Idnum, doc.lastTimeOfCall ], null);\u000a}" } } } I have fired this command from curl command : curl -X GET http://uta:password@localhost:5984/person-data/_design/persondestwo/_view/personviewtwo?startkey=["SRINI","383896"]&amp;endkey=["SRINI","383896",{}]descending=true&amp;include_docs=true </code></pre> <p>I got this error :</p> <pre><code>[4] 3000 curl: (3) [globbing] error: bad range specification after pos 99 [5] 1776 [6] 2736 [3] Done descending=true [4] Done(3) curl -X GET http://uta:password@localhost:5984/person-data/_design/persondestwo/_view/personviewtwo?startkey=["SRINI","383896"] [5] Done endkey=["SRINI","383896"] </code></pre> <p>I am not knowing what this error is.</p> <p>I have also tried passing the parameters the below way and it is not helping</p> <pre><code>curl -X GET http://uta:password@localhost:5984/person-data/_design/persondestwo/_view/personviewtwo?key={\"Name\":\"SRINI\",\"Idnum\": \"383896\"}&amp;descending=true </code></pre> <p>But I get different errors on escape sequences </p> <p>Overall I just want this query to be satisfied through the view :</p> <pre><code>select * from person-data where Name="SRINI" and Idnum="383896" orderby lastTimeOfCall </code></pre> <p>My concern is how to pass the multiple parameters from curl command as I get lot of errors if I do the above way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload