You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Rizwan Chouhan <ch...@gmail.com> on 2021/12/14 11:36:39 UTC
couch db top sold products by date and store id, grouping and filtering by multiple keys
Hii Team,
I am RIZWAN CHOUHAN from RAPUR, CHHATTISGARH, INDIA, an engineering student
and entrepreneur. I want to learn couchdb at its core and experience its
power . I want to see the list of products sold in particular by store id.
writing the whole scenario would not be easy here in the mail so I made one
public gist so I could explain the problem I am facing .
https://gist.github.com/rizwan92/562d0ce05841661e555c5de7cb325b60
please help me and guide me what i am doing wrong
Re: couch db top sold products by date and store id, grouping and filtering by multiple keys
Posted by Olaf Krüger <ok...@apache.org>.
> no i just want to aggregate my my data by product name only
You told us this within your gist:
// if user selects 13 of december
prod1. 28 times sold 5614 dollar earns
prod2. 1 times sold 20 dollar earns
That still sounds to me that you want to aggregate your data by date at the first level
(" if user selects 13 of december").
Notice that the index key works from left to right. So, I think you need to emit the date at first key item.
Of course, I could be wrong!
Olaf
Re: couch db top sold products by date and store id, grouping and filtering by multiple keys
Posted by Rizwan Chouhan <ch...@gmail.com>.
@olaf
> It looks like you want to aggregate your data by "createdAt" at the first
> level.
no i just want to aggregate my my data by product name only
"outletId" seems to be not part of your document at your gist.
i updated gist my document is very large i only write relevant part not
whole object any way now i have updated it now
please tell me how to pull top selling products and by date and store id
On Tue, Dec 14, 2021 at 6:31 PM Rizwan Chouhan <ch...@gmail.com>
wrote:
> @olaf
>
>
>> It looks like you want to aggregate your data by "createdAt" at the first
>> level.
>
>
> no i just want to aggregate my my data by product name only
>
> "outletId" seems to be not part of your document at your gist.
>
>
> On Tue, Dec 14, 2021 at 6:10 PM Olaf Krüger <ok...@apache.org> wrote:
>
>> Hi,
>>
>> > please help me and guide me what i am doing wrong
>>
>> I just took a quick look into your gist:
>> It looks like you want to aggregate your data by "createdAt" at the first
>> level.
>> If so, it might makes sense to start with the date within your key:
>> emit(["createdAt", "outletId", "name"], ...)
>>
>> BTW 1:
>> You might want to use "createdAt.substring(0,10)" in order to extraxt the
>> date instead of invoking "Date()" a couple of times.
>>
>> BTW 2:
>> "outletId" seems to be not part of your document at your gist.
>>
>> Maybe this helps,
>> Olaf
>>
>
Re: couch db top sold products by date and store id, grouping and filtering by multiple keys
Posted by Rizwan Chouhan <ch...@gmail.com>.
@olaf
> It looks like you want to aggregate your data by "createdAt" at the first
> level.
no i just want to aggregate my my data by product name only
"outletId" seems to be not part of your document at your gist.
On Tue, Dec 14, 2021 at 6:10 PM Olaf Krüger <ok...@apache.org> wrote:
> Hi,
>
> > please help me and guide me what i am doing wrong
>
> I just took a quick look into your gist:
> It looks like you want to aggregate your data by "createdAt" at the first
> level.
> If so, it might makes sense to start with the date within your key:
> emit(["createdAt", "outletId", "name"], ...)
>
> BTW 1:
> You might want to use "createdAt.substring(0,10)" in order to extraxt the
> date instead of invoking "Date()" a couple of times.
>
> BTW 2:
> "outletId" seems to be not part of your document at your gist.
>
> Maybe this helps,
> Olaf
>
Re: couch db top sold products by date and store id, grouping and filtering by multiple keys
Posted by Olaf Krüger <ok...@apache.org>.
Hi,
> please help me and guide me what i am doing wrong
I just took a quick look into your gist:
It looks like you want to aggregate your data by "createdAt" at the first level.
If so, it might makes sense to start with the date within your key:
emit(["createdAt", "outletId", "name"], ...)
BTW 1:
You might want to use "createdAt.substring(0,10)" in order to extraxt the date instead of invoking "Date()" a couple of times.
BTW 2:
"outletId" seems to be not part of your document at your gist.
Maybe this helps,
Olaf