Need to find no of logins each week MongoDB
I have two collections. I am trying to find the count of logins based upon a LoggedTime field. I would like to get the no of logins per week for past five weeks.
I have two collections.
collection 1 : Role
Fields : Role, UserName , loggedTime
collection 2 :mysite
Fields : userName ,userEmail ,name
In collection 1: eg :
{ 'Role' :"admin" 'UserName' : "abc.efg", 'loggedTime' : 2020-06-24T18:12:03.455Z, } In collection 2: eg:
{ 'userName' : "abc Mr, efg" , 'userEmail' : "abc.efg@company.com" , 'name' : 'orgname' }
Is there any way where we can have a new collection which has count of no of logins(based on loggedTime) per week by each orgname for past 5 weeks.
Basically trying to get result like collection 3: { name :'orgname', 'Logins current week':'no of logins' 'Logins previous week' : 'no of logins' 'Logins 3rd week' :'no of logins' 'Logins 4th week' :'no of logins' 'Logins 5th week': 'no of logins' }
Thanks in advance
from Recent Questions - Stack Overflow https://ift.tt/35DUomW
https://ift.tt/eA8V8J
Comments
Post a Comment