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/05/22 07:52:56 UTC

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

Hello Folks :)

I learn to make a very simple accounting app using CouchDB as my data
storage.
I need to create balance sheet report, and certainly the report must be
able to show by date periode
(example: from 2013-01-01 unti 2013-0131) . My plan is create two view. And
i will doing query 2 times.
The 1st view will give me data filtered by date range. The 2nd view will
filter data from 1st view by account number range.
So.. i need to know, how to passing 1st view data to 2nd view?

Ok, what i've done so far is created two view with two different key
arrangement.
My 1st view http://easycaptures.com/fs/uploaded/641/0865962213.png named
journal_date_acc which is
having date-accountNumber key arrangement. ["2013/05/14", 1000, 1010, 1011]
then My 2nd view
http://easycaptures.com/fs/uploaded/641/2476449270.pngnamed
journal_acc_date which is
having accountNumber-date key arrangement. [1000, 1010, 1011, "2013/05/14"]

And this is my document structure http://pastebin.com/RUrBYMWR .

I've test my views, and i doing test bellow:
this is for my 1st view
http://host:5984/myfinance/_design/journal/_view/journal_date_acc?group=true&startkey=[
"2013/05/14"]&endkey=["2013/05/16"]
{"rows":[
{"key":["2013/05/14",1000,1010,1011],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
Kantor Pusat"}},
{"key":["2013/05/14",1000,1100,1101],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
Dinas"}},
{"key":["2013/05/14",5000,5100,5101],"value":{"debit":10000000,"credit":0,"totalItem":1,"accLevel1Desc":"Biaya_dan_Beban","accLevel2Desc":"Gaji","accLevel3Desc":"Gaji
Karyawan Bagian Penjualan"}}
]}


this is test for my 2nd view
http://host:5984/myfinance/_design/journal/_view/journal_acc_date?group=true&startkey=[1000,1010,1011,
"2013/05/14"]&endkey=[1000,1100,1101,"2013/05/16"]
{"rows":[
{"key":[1000,1010,1011,"2013/05/14"],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
Kantor Pusat"}},
{"key":[1000,1100,1101,"2013/05/14"],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
Dinas"}}
]}

Ok, once again, how to passing 1st view data to 2nd view? I want to filter
data by date range in 1st view,,  then i want to filter it again
by account number range in 2nd view. How to?

Thank You :)

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

Posted by Benoit Chesneau <bc...@gmail.com>.
in rcouch [1] an alternative distribution of couchdb you can simply
replicate your views results to a db then do what you want with them.

- benoit

[1] http://rcouch.org
 On May 22, 2013 11:40 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 <an...@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.
>

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

Posted by Nick North <no...@gmail.com>.
Just a small thing, but you seem to have "debit" in some places and "debet"
in others. This will cause the reduce function to miss data when its input
is the result of a reduction.

Nick


On 22 May 2013 11:30, polutan <li...@gmail.com> wrote:

> @ALL
> Ok.. i ended up with this view.
> http://easycaptures.com/fs/uploaded/641/0865962213.png
> i will filter out manually by account number outside of couchdb.
> any other advice?
>
> Thank You :)
>
>
>
>
> 2013/5/22 Aurélien Bénel <au...@utt.fr>
>
> > Hi Polutan,
> >
> > >>> The 1st view will give me data filtered by date range. The 2nd view
> > will filter data from 1st view by account number range. So.. i need to
> > know, how to passing 1st view data to 2nd view?
> > >> You're running into some very basic (intentional) design limits in
> > couchdb.
> > > What??? I can't believe it :(
> > > So. any other alternative for my case?
> >
> > Did you try with combined keys?
> > What you can do with them still impress me.
> >
> > > I suggest you take a bit of time out and read the free & awesome
> > definitive guide http://guide.couchdb.org/draft/index.html first.
> >
> >
> > I second that. Most of what you will ask in the several days are probably
> > already there... and well written ;)
> >
> >
> > Regards,
> >
> > Aurélien
>
>
>
>
> --
> *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.
>

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

Posted by polutan <li...@gmail.com>.
Ok.. i will read http://guide.couchdb.org/draft/index.html .


2013/5/22 polutan <li...@gmail.com>

> @ALL
> Ok.. i ended up with this view.
> http://easycaptures.com/fs/uploaded/641/0865962213.png
> i will filter out manually by account number outside of couchdb.
> any other advice?
>
> Thank You :)
>
>
>
>
> 2013/5/22 Aurélien Bénel <au...@utt.fr>
>
>> Hi Polutan,
>>
>> >>> The 1st view will give me data filtered by date range. The 2nd view
>> will filter data from 1st view by account number range. So.. i need to
>> know, how to passing 1st view data to 2nd view?
>> >> You're running into some very basic (intentional) design limits in
>> couchdb.
>> > What??? I can't believe it :(
>> > So. any other alternative for my case?
>>
>> Did you try with combined keys?
>> What you can do with them still impress me.
>>
>> > I suggest you take a bit of time out and read the free & awesome
>> definitive guide http://guide.couchdb.org/draft/index.html first.
>>
>>
>> I second that. Most of what you will ask in the several days are probably
>> already there... and well written ;)
>>
>>
>> Regards,
>>
>> Aurélien
>
>
>
>
> --
> *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.

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

Posted by polutan <li...@gmail.com>.
@ALL
Ok.. i ended up with this view.
http://easycaptures.com/fs/uploaded/641/0865962213.png
i will filter out manually by account number outside of couchdb.
any other advice?

Thank You :)




2013/5/22 Aurélien Bénel <au...@utt.fr>

> Hi Polutan,
>
> >>> The 1st view will give me data filtered by date range. The 2nd view
> will filter data from 1st view by account number range. So.. i need to
> know, how to passing 1st view data to 2nd view?
> >> You're running into some very basic (intentional) design limits in
> couchdb.
> > What??? I can't believe it :(
> > So. any other alternative for my case?
>
> Did you try with combined keys?
> What you can do with them still impress me.
>
> > I suggest you take a bit of time out and read the free & awesome
> definitive guide http://guide.couchdb.org/draft/index.html first.
>
>
> I second that. Most of what you will ask in the several days are probably
> already there... and well written ;)
>
>
> Regards,
>
> Aurélien




-- 
*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.

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

Posted by Aurélien Bénel <au...@utt.fr>.
Hi Polutan,

>>> The 1st view will give me data filtered by date range. The 2nd view will filter data from 1st view by account number range. So.. i need to know, how to passing 1st view data to 2nd view?
>> You're running into some very basic (intentional) design limits in couchdb.
> What??? I can't believe it :(
> So. any other alternative for my case?

Did you try with combined keys?
What you can do with them still impress me.

> I suggest you take a bit of time out and read the free & awesome definitive guide http://guide.couchdb.org/draft/index.html first. 


I second that. Most of what you will ask in the several days are probably already there... and well written ;)


Regards,

Aurélien

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

Posted by polutan <li...@gmail.com>.
@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.

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

Posted by 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 <an...@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.
>
>

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

Posted by Garren Smith <ga...@apache.org>.
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 <an...@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.


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

Posted by polutan <li...@gmail.com>.
@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 <an...@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.

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

Posted by 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 <an...@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.


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

Posted by polutan <li...@gmail.com>.
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 <an...@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.

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

Posted by Dave Cottlehuber <dc...@jsonified.com>.
On 22 May 2013 09:37, Andrey Kuprianov <an...@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!

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

Posted by Andrey Kuprianov <an...@gmail.com>.
Hi,

There's a 1st edition available, as opposed to reading a draft:
http://guide.couchdb.org/editions/1/en/index.html

  Andrey


On Wed, May 22, 2013 at 3:27 PM, Dave Cottlehuber <dc...@jsonified.com> wrote:

> On 22 May 2013 07:52, polutan <li...@gmail.com> wrote:
> > Hello Folks :)
> >
> > I learn to make a very simple accounting app using CouchDB as my data
> > storage.
> > I need to create balance sheet report, and certainly the report must be
> > able to show by date periode
> > (example: from 2013-01-01 unti 2013-0131) . My plan is create two view.
> And
> > i will doing query 2 times.
> > The 1st view will give me data filtered by date range. The 2nd view will
> > filter data from 1st view by account number range.
> > So.. i need to know, how to passing 1st view data to 2nd view?
> >
> > Ok, what i've done so far is created two view with two different key
> > arrangement.
> > My 1st view http://easycaptures.com/fs/uploaded/641/0865962213.png named
> > journal_date_acc which is
> > having date-accountNumber key arrangement. ["2013/05/14", 1000, 1010,
> 1011]
> > then My 2nd view
> > http://easycaptures.com/fs/uploaded/641/2476449270.pngnamed
> > journal_acc_date which is
> > having accountNumber-date key arrangement. [1000, 1010, 1011,
> "2013/05/14"]
> >
> > And this is my document structure http://pastebin.com/RUrBYMWR .
> >
> > I've test my views, and i doing test bellow:
> > this is for my 1st view
> >
> http://host:5984/myfinance/_design/journal/_view/journal_date_acc?group=true&startkey=[
> > "2013/05/14"]&endkey=["2013/05/16"]
> > {"rows":[
> >
> {"key":["2013/05/14",1000,1010,1011],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> > Kantor Pusat"}},
> >
> {"key":["2013/05/14",1000,1100,1101],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> > Dinas"}},
> >
> {"key":["2013/05/14",5000,5100,5101],"value":{"debit":10000000,"credit":0,"totalItem":1,"accLevel1Desc":"Biaya_dan_Beban","accLevel2Desc":"Gaji","accLevel3Desc":"Gaji
> > Karyawan Bagian Penjualan"}}
> > ]}
> >
> >
> > this is test for my 2nd view
> >
> http://host:5984/myfinance/_design/journal/_view/journal_acc_date?group=true&startkey=[1000,1010,1011
> ,
> > "2013/05/14"]&endkey=[1000,1100,1101,"2013/05/16"]
> > {"rows":[
> >
> {"key":[1000,1010,1011,"2013/05/14"],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> > Kantor Pusat"}},
> >
> {"key":[1000,1100,1101,"2013/05/14"],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> > Dinas"}}
> > ]}
> >
> > Ok, once again, how to passing 1st view data to 2nd view? I want to
> filter
> > data by date range in 1st view,,  then i want to filter it again
> > by account number range in 2nd view. How to?
> >
> > Thank You :)
>
> Hi Polutan,
>
> You're running into some very basic (intentional) design limits in
> couchdb. I suggest you take a bit of time out and read the free &
> awesome definitive guide http://guide.couchdb.org/draft/index.html
> first. It will save you a lot of time headbanging against stuff that
> isn't possible. The sofa chapter is sadly out of date, so skip that,
> but the concepts and explanations of how couchdb works are still
> relevant.
>
> Multi-set operations such as intersections and unions need to be done
> outside CouchDB, in general.
>
> So you'll need to query one view, then the other, and then process as
> appropriate.
>
> A+
> Dave
>

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

Posted by Dave Cottlehuber <dc...@jsonified.com>.
On 22 May 2013 07:52, polutan <li...@gmail.com> wrote:
> Hello Folks :)
>
> I learn to make a very simple accounting app using CouchDB as my data
> storage.
> I need to create balance sheet report, and certainly the report must be
> able to show by date periode
> (example: from 2013-01-01 unti 2013-0131) . My plan is create two view. And
> i will doing query 2 times.
> The 1st view will give me data filtered by date range. The 2nd view will
> filter data from 1st view by account number range.
> So.. i need to know, how to passing 1st view data to 2nd view?
>
> Ok, what i've done so far is created two view with two different key
> arrangement.
> My 1st view http://easycaptures.com/fs/uploaded/641/0865962213.png named
> journal_date_acc which is
> having date-accountNumber key arrangement. ["2013/05/14", 1000, 1010, 1011]
> then My 2nd view
> http://easycaptures.com/fs/uploaded/641/2476449270.pngnamed
> journal_acc_date which is
> having accountNumber-date key arrangement. [1000, 1010, 1011, "2013/05/14"]
>
> And this is my document structure http://pastebin.com/RUrBYMWR .
>
> I've test my views, and i doing test bellow:
> this is for my 1st view
> http://host:5984/myfinance/_design/journal/_view/journal_date_acc?group=true&startkey=[
> "2013/05/14"]&endkey=["2013/05/16"]
> {"rows":[
> {"key":["2013/05/14",1000,1010,1011],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> Kantor Pusat"}},
> {"key":["2013/05/14",1000,1100,1101],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> Dinas"}},
> {"key":["2013/05/14",5000,5100,5101],"value":{"debit":10000000,"credit":0,"totalItem":1,"accLevel1Desc":"Biaya_dan_Beban","accLevel2Desc":"Gaji","accLevel3Desc":"Gaji
> Karyawan Bagian Penjualan"}}
> ]}
>
>
> this is test for my 2nd view
> http://host:5984/myfinance/_design/journal/_view/journal_acc_date?group=true&startkey=[1000,1010,1011,
> "2013/05/14"]&endkey=[1000,1100,1101,"2013/05/16"]
> {"rows":[
> {"key":[1000,1010,1011,"2013/05/14"],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> Kantor Pusat"}},
> {"key":[1000,1100,1101,"2013/05/14"],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> Dinas"}}
> ]}
>
> Ok, once again, how to passing 1st view data to 2nd view? I want to filter
> data by date range in 1st view,,  then i want to filter it again
> by account number range in 2nd view. How to?
>
> Thank You :)

Hi Polutan,

You're running into some very basic (intentional) design limits in
couchdb. I suggest you take a bit of time out and read the free &
awesome definitive guide http://guide.couchdb.org/draft/index.html
first. It will save you a lot of time headbanging against stuff that
isn't possible. The sofa chapter is sadly out of date, so skip that,
but the concepts and explanations of how couchdb works are still
relevant.

Multi-set operations such as intersections and unions need to be done
outside CouchDB, in general.

So you'll need to query one view, then the other, and then process as
appropriate.

A+
Dave

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

Posted by Nick North <no...@gmail.com>.
There is a discussion of why transactions are not necessary at http://guide.couchdb.org/draft/recipes.html.

Nick

On 1 Jun 2013, at 19:59, Robert Newson <ro...@gmail.com> wrote:

> Document updates are atomic.
> On 1 Jun 2013 18:12, "Brad Rhoads" <bd...@gmail.com> wrote:
> 
>> You dont have atomic transactions in couchdb. So it might not be the right
>> db for an accounting app.
>> On May 21, 2013 11:53 PM, "polutan" <li...@gmail.com> wrote:
>> 
>>> Hello Folks :)
>>> 
>>> I learn to make a very simple accounting app using CouchDB as my data
>>> storage.
>>> I need to create balance sheet report, and certainly the report must be
>>> able to show by date periode
>>> (example: from 2013-01-01 unti 2013-0131) . My plan is create two view.
>> And
>>> i will doing query 2 times.
>>> The 1st view will give me data filtered by date range. The 2nd view will
>>> filter data from 1st view by account number range.
>>> So.. i need to know, how to passing 1st view data to 2nd view?
>>> 
>>> Ok, what i've done so far is created two view with two different key
>>> arrangement.
>>> My 1st view http://easycaptures.com/fs/uploaded/641/0865962213.png named
>>> journal_date_acc which is
>>> having date-accountNumber key arrangement. ["2013/05/14", 1000, 1010,
>> 1011]
>>> then My 2nd view
>>> http://easycaptures.com/fs/uploaded/641/2476449270.pngnamed
>>> journal_acc_date which is
>>> having accountNumber-date key arrangement. [1000, 1010, 1011,
>> "2013/05/14"]
>>> 
>>> And this is my document structure http://pastebin.com/RUrBYMWR .
>>> 
>>> I've test my views, and i doing test bellow:
>>> this is for my 1st view
>> http://host:5984/myfinance/_design/journal/_view/journal_date_acc?group=true&startkey=[
>>> "2013/05/14"]&endkey=["2013/05/16"]
>>> {"rows":[
>> {"key":["2013/05/14",1000,1010,1011],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
>>> Kantor Pusat"}},
>> {"key":["2013/05/14",1000,1100,1101],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
>>> Dinas"}},
>> {"key":["2013/05/14",5000,5100,5101],"value":{"debit":10000000,"credit":0,"totalItem":1,"accLevel1Desc":"Biaya_dan_Beban","accLevel2Desc":"Gaji","accLevel3Desc":"Gaji
>>> Karyawan Bagian Penjualan"}}
>>> ]}
>>> 
>>> 
>>> this is test for my 2nd view
>> http://host:5984/myfinance/_design/journal/_view/journal_acc_date?group=true&startkey=[1000,1010,1011
>>> ,
>>> "2013/05/14"]&endkey=[1000,1100,1101,"2013/05/16"]
>>> {"rows":[
>> {"key":[1000,1010,1011,"2013/05/14"],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
>>> Kantor Pusat"}},
>> {"key":[1000,1100,1101,"2013/05/14"],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
>>> Dinas"}}
>>> ]}
>>> 
>>> Ok, once again, how to passing 1st view data to 2nd view? I want to
>> filter
>>> data by date range in 1st view,,  then i want to filter it again
>>> by account number range in 2nd view. How to?
>>> 
>>> Thank You :)
>> 

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

Posted by Robert Newson <ro...@gmail.com>.
Document updates are atomic.
On 1 Jun 2013 18:12, "Brad Rhoads" <bd...@gmail.com> wrote:

> You dont have atomic transactions in couchdb. So it might not be the right
> db for an accounting app.
> On May 21, 2013 11:53 PM, "polutan" <li...@gmail.com> wrote:
>
> > Hello Folks :)
> >
> > I learn to make a very simple accounting app using CouchDB as my data
> > storage.
> > I need to create balance sheet report, and certainly the report must be
> > able to show by date periode
> > (example: from 2013-01-01 unti 2013-0131) . My plan is create two view.
> And
> > i will doing query 2 times.
> > The 1st view will give me data filtered by date range. The 2nd view will
> > filter data from 1st view by account number range.
> > So.. i need to know, how to passing 1st view data to 2nd view?
> >
> > Ok, what i've done so far is created two view with two different key
> > arrangement.
> > My 1st view http://easycaptures.com/fs/uploaded/641/0865962213.png named
> > journal_date_acc which is
> > having date-accountNumber key arrangement. ["2013/05/14", 1000, 1010,
> 1011]
> > then My 2nd view
> > http://easycaptures.com/fs/uploaded/641/2476449270.pngnamed
> > journal_acc_date which is
> > having accountNumber-date key arrangement. [1000, 1010, 1011,
> "2013/05/14"]
> >
> > And this is my document structure http://pastebin.com/RUrBYMWR .
> >
> > I've test my views, and i doing test bellow:
> > this is for my 1st view
> >
> >
> http://host:5984/myfinance/_design/journal/_view/journal_date_acc?group=true&startkey=[
> > "2013/05/14"]&endkey=["2013/05/16"]
> > {"rows":[
> >
> >
> {"key":["2013/05/14",1000,1010,1011],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> > Kantor Pusat"}},
> >
> >
> {"key":["2013/05/14",1000,1100,1101],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> > Dinas"}},
> >
> >
> {"key":["2013/05/14",5000,5100,5101],"value":{"debit":10000000,"credit":0,"totalItem":1,"accLevel1Desc":"Biaya_dan_Beban","accLevel2Desc":"Gaji","accLevel3Desc":"Gaji
> > Karyawan Bagian Penjualan"}}
> > ]}
> >
> >
> > this is test for my 2nd view
> >
> >
> http://host:5984/myfinance/_design/journal/_view/journal_acc_date?group=true&startkey=[1000,1010,1011
> > ,
> > "2013/05/14"]&endkey=[1000,1100,1101,"2013/05/16"]
> > {"rows":[
> >
> >
> {"key":[1000,1010,1011,"2013/05/14"],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> > Kantor Pusat"}},
> >
> >
> {"key":[1000,1100,1101,"2013/05/14"],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> > Dinas"}}
> > ]}
> >
> > Ok, once again, how to passing 1st view data to 2nd view? I want to
> filter
> > data by date range in 1st view,,  then i want to filter it again
> > by account number range in 2nd view. How to?
> >
> > Thank You :)
> >
>

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

Posted by Brad Rhoads <bd...@gmail.com>.
You dont have atomic transactions in couchdb. So it might not be the right
db for an accounting app.
On May 21, 2013 11:53 PM, "polutan" <li...@gmail.com> wrote:

> Hello Folks :)
>
> I learn to make a very simple accounting app using CouchDB as my data
> storage.
> I need to create balance sheet report, and certainly the report must be
> able to show by date periode
> (example: from 2013-01-01 unti 2013-0131) . My plan is create two view. And
> i will doing query 2 times.
> The 1st view will give me data filtered by date range. The 2nd view will
> filter data from 1st view by account number range.
> So.. i need to know, how to passing 1st view data to 2nd view?
>
> Ok, what i've done so far is created two view with two different key
> arrangement.
> My 1st view http://easycaptures.com/fs/uploaded/641/0865962213.png named
> journal_date_acc which is
> having date-accountNumber key arrangement. ["2013/05/14", 1000, 1010, 1011]
> then My 2nd view
> http://easycaptures.com/fs/uploaded/641/2476449270.pngnamed
> journal_acc_date which is
> having accountNumber-date key arrangement. [1000, 1010, 1011, "2013/05/14"]
>
> And this is my document structure http://pastebin.com/RUrBYMWR .
>
> I've test my views, and i doing test bellow:
> this is for my 1st view
>
> http://host:5984/myfinance/_design/journal/_view/journal_date_acc?group=true&startkey=[
> "2013/05/14"]&endkey=["2013/05/16"]
> {"rows":[
>
> {"key":["2013/05/14",1000,1010,1011],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> Kantor Pusat"}},
>
> {"key":["2013/05/14",1000,1100,1101],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> Dinas"}},
>
> {"key":["2013/05/14",5000,5100,5101],"value":{"debit":10000000,"credit":0,"totalItem":1,"accLevel1Desc":"Biaya_dan_Beban","accLevel2Desc":"Gaji","accLevel3Desc":"Gaji
> Karyawan Bagian Penjualan"}}
> ]}
>
>
> this is test for my 2nd view
>
> http://host:5984/myfinance/_design/journal/_view/journal_acc_date?group=true&startkey=[1000,1010,1011
> ,
> "2013/05/14"]&endkey=[1000,1100,1101,"2013/05/16"]
> {"rows":[
>
> {"key":[1000,1010,1011,"2013/05/14"],"value":{"debit":0,"credit":60000000,"totalItem":2,"accLevel1Desc":"Aset","accLevel2Desc":"Kas","accLevel3Desc":"Kas
> Kantor Pusat"}},
>
> {"key":[1000,1100,1101,"2013/05/14"],"value":{"debit":50000000,"credit":0,"totalItem":1,"accLevel1Desc":"Aset","accLevel2Desc":"Kendaraan","accLevel3Desc":"Mobil
> Dinas"}}
> ]}
>
> Ok, once again, how to passing 1st view data to 2nd view? I want to filter
> data by date range in 1st view,,  then i want to filter it again
> by account number range in 2nd view. How to?
>
> Thank You :)
>