I have two arrays as below:
LastOneYearCustomerIds:[1,2,3,4,5,6,7,8]
ThisMonthCustomerIds:[1,2,3,4,9,10]
I need to find the New Customer Ids which were not in previous year. I tried creating one pipeline in MongoDB Compass but it will give the difference, I am looking for something which can return me elements in ThisMonthCustomerIds but not in LastOneYearCustomerIds. I also tried following other posts on stack overflow but couldn't find a relevant solution.
Expected Result is:
NewCustomerIds:[9,10]
I have tried below Aggregation pipeline which will give me the difference but not new CustomerIds:
$project: {
newCustomerIds:{
$setDifference:
['$LastOneYearCustomerIds','$ThisMonthCustomerIds'
]}
}