You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mobashir Hasan <th...@hotmail.com> on 2012/08/07 06:40:33 UTC

Document filter and sorting

Hi,
I'm new to couchdb and have stuck badly, I have a listing page where I display the documents that has some specific values.Now what I have to do is to filter these document by different user inputs and sorting the documents by different columns.I have 6 columns in my documents.Date to, Date from, Name, City, State, Country, Zip
when user inputs city and hit filter so it should display documents of that city only.Similarly, when user click on column name "City" it should sort / asc / desc.
Work environment is JavaScript / html only.
Any help will be highly appreciated.
Thanks,Mobashir 		 	   		   		 	   		  

RE: Document filter and sorting

Posted by Mobashir Hasan <th...@hotmail.com>.
Thanks Simon, it helped me alot :)

Mobashir

> Date: Tue, 7 Aug 2012 10:14:46 +0100
> From: simon@cloudant.com
> To: user@couchdb.apache.org
> Subject: Re: Document filter and sorting
> 
> Hi, 
> To do the table sort I'd use client side javascript (for example http://datatables.net (http://datatables.net/)). Depending on the size of your dataset that might be sufficient to do the filtering, too. 
> 
> If you have a really large dataset (e.g. one that can't entirely be sent to the client) you can make the view keyed by city (you might want to have a key that's [Country, State, City], since there are cities that have the same name) and then query the list function (and corresponding view) with ?key="The City" (or key=["The country", "The state", "The city"] if you go with a complex key). 
> 
> Hope that helps
> Simon
> 
> 
> On Tuesday, 7 August 2012 at 05:40, Mobashir Hasan wrote:
> 
> > 
> > Hi,
> > I'm new to couchdb and have stuck badly, I have a listing page where I display the documents that has some specific values.Now what I have to do is to filter these document by different user inputs and sorting the documents by different columns.I have 6 columns in my documents.Date to, Date from, Name, City, State, Country, Zip
> > when user inputs city and hit filter so it should display documents of that city only.Similarly, when user click on column name "City" it should sort / asc / desc.
> > Work environment is JavaScript / html only.
> > Any help will be highly appreciated.
> > Thanks,Mobashir 
> > 
> > 
> 
> 
 		 	   		  

Re: Document filter and sorting

Posted by Simon Metson <si...@cloudant.com>.
Hi, 
To do the table sort I'd use client side javascript (for example http://datatables.net (http://datatables.net/)). Depending on the size of your dataset that might be sufficient to do the filtering, too. 

If you have a really large dataset (e.g. one that can't entirely be sent to the client) you can make the view keyed by city (you might want to have a key that's [Country, State, City], since there are cities that have the same name) and then query the list function (and corresponding view) with ?key="The City" (or key=["The country", "The state", "The city"] if you go with a complex key). 

Hope that helps
Simon


On Tuesday, 7 August 2012 at 05:40, Mobashir Hasan wrote:

> 
> Hi,
> I'm new to couchdb and have stuck badly, I have a listing page where I display the documents that has some specific values.Now what I have to do is to filter these document by different user inputs and sorting the documents by different columns.I have 6 columns in my documents.Date to, Date from, Name, City, State, Country, Zip
> when user inputs city and hit filter so it should display documents of that city only.Similarly, when user click on column name "City" it should sort / asc / desc.
> Work environment is JavaScript / html only.
> Any help will be highly appreciated.
> Thanks,Mobashir 
> 
>