You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by polutan <li...@gmail.com> on 2013/06/01 18:51:40 UTC

Re: [ASK] How to passing 1st view data to 2nd view??

@Garren
Ok, Thank you very much for your example. I Understand.

@Nick
Thank you nick :)

@ALL
wuffhhh...this is a tough start for me to start using couchdb. Ok keep
spirit! keep spirit!! :)
thank you



2013/5/29 Nick North <no...@gmail.com>

> It would still be worth having the view that sums all entries in a date
> range and group at the right level so that you get back the total change in
> the account balance over the range. This is particularly useful if you want
> to get the opening balance, when you'll need to sum over all entries up to
> the opening date of the report.
>
> As a balance sheet needs multiple accounts, you'd need to query the view
> once per account to construct the report.
>
> Nick
>
>
>
> On 29 May 2013 08:00, Garren Smith <ga...@apache.org> wrote:
>
> > Hi Polutan,
> >
> > I don't know the full context of your problem. But I think you should be
> > able to do something like this:
> > Create a view with a map:
> >
> > function (doc) {
> >         var t = new Date(doc['dateOfEntry');
> >         emit([doc.accountName, t.getFullYear(), t.getMonth(),
> t.getDay()],
> > 1);
> > }
> >
> > You would most likely have to create some if clauses to check the doc has
> > all these values.
> >
> > When you query the view you use the following parameters:
> > start_key = ["MyAccountName", 2013,1,1 ] - Change the date to be the
> start
> > of time range that you want your data for.
> > end_key = ["MyAccountName", 2013,12,31] - Again change the date range to
> > suit your needs
> > include_docs = true - so you get the docs.
> >
> > This should give you all the docs for your account in the specific date
> > range.
> >
> > Cheers
> > Garren
> >
> >
> > On 28 May 2013, at 5:49 PM, polutan <li...@gmail.com> wrote:
> >
> > > @Garren
> > > Hi Garren :) thank you for your reply.
> > > But i still don't understand with your explanation. Please give me an
> > > example. I don't understand with ur statement " emit that date range as
> > > well as the account number" .
> > >
> > > Thank You :)
> > >
> > >
> > > 2013/5/22 Garren Smith <ga...@apache.org>
> > >
> > >> Hi Polutan,
> > >>
> > >> I think you could get what you want by just using one view. For your
> > view
> > >> keys emit that date range as well as the account number. Then when you
> > do a
> > >> query of the data include the date range as well as the account number
> > that
> > >> you want this data for. Couchdb will then return the balance sheet
> > entries
> > >> for that date range belonging to your account number.
> > >>
> > >> Cheers
> > >> Garren
> > >>
> > >> On 22 May 2013, at 11:39 AM, polutan <li...@gmail.com> wrote:
> > >>
> > >>> What??? I can't believe it :(
> > >>> So. any other alternative for my case?
> > >>>
> > >>> Thank You :)
> > >>>
> > >>>
> > >>> 2013/5/22 Dave Cottlehuber <dc...@jsonified.com>
> > >>>
> > >>>> On 22 May 2013 09:37, Andrey Kuprianov <andrey.kouprianov@gmail.com
> >
> > >>>> wrote:
> > >>>>> Hi,
> > >>>>>
> > >>>>> There's a 1st edition available, as opposed to reading a draft:
> > >>>>> http://guide.couchdb.org/editions/1/en/index.html
> > >>>>>
> > >>>>> Andrey
> > >>>>
> > >>>> The draft ironically is the newer 1.x release edition. Confusing!
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>> --
> > >>> *Coklat Stroberi -- Web Dev Training Centre*
> > >>> http://www.facebook.com/pages/Coklat-Stroberi/249514251728226  (info
> > >> lebih
> > >>> lanjut)
> > >>> http://coklatstroberi.net
> > >>> Jl. Raya Padang Luwih (Dalung) No.141 - Telp. (0361) 9006118 atau
> > >>> 08174128301 - Badung, Bali. Sebelah timur traffic light pertigaan
> > >> perumahan
> > >>> dalung permai.
> > >>
> > >>
> > >
> > >
> > > --
> > > *Coklat Stroberi -- Web Dev Training Centre*
> > > http://www.facebook.com/pages/Coklat-Stroberi/249514251728226  (info
> > lebih
> > > lanjut)
> > > http://coklatstroberi.net
> > > Jl. Raya Padang Luwih (Dalung) No.141 - Telp. (0361) 9006118 atau
> > > 08174128301 - Badung, Bali. Sebelah timur traffic light pertigaan
> > perumahan
> > > dalung permai.
> >
> >
>



-- 
*Coklat Stroberi -- Web Dev Training Centre*
http://www.facebook.com/pages/Coklat-Stroberi/249514251728226  (info lebih
lanjut)
http://coklatstroberi.net
Jl. Raya Padang Luwih (Dalung) No.141 - Telp. (0361) 9006118 atau
08174128301 - Badung, Bali. Sebelah timur traffic light pertigaan perumahan
dalung permai.