Skip to content

Instantly share code, notes, and snippets.

Avatar

Elvis Rozario Visrozar

View GitHub Profile
View Aggregation first solution
db.collection.aggregate([
{
"$project": {
"_id": 1,
"product": 1,
"day": {
"$dayOfMonth": "$time"
},
"month": {
"$month": "$time"
View Aggregation fourth solution
db.collection.aggregate([
{
"$group": {
"_id": {
"$dateToString": {
"format": "%Y-%m-%d",
"date": "$time"
}
},
"count": {
View Aggregation second solution
db.collection.aggregate([
{
"$project": {
"_id": 1,
"product": 1,
"time": {
"$dateToString": {
"format": "%Y-%m-%d",
"date": "$time"
}
View Aggregation third solution
db.collection.aggregate([
{
"$group": {
"_id": {
"date": {
$dateToString: {
format: "%Y-%m-%d",
date: "$time"
}
},
You can’t perform that action at this time.