I have a document that includes a field like this:
{
...
log: [
{
utc_timestamp: ISODate("2014-11-15T10:26:47.337Z"),
type: "clicked"
},
{
utc_timestamp: ISODate("2014-10-15T16:12:51.959Z"),
type: "emailed"
},
{
utc_timestamp: ISODate("2014-10-15T16:10:51.959Z"),
type: "clicked"
},
{
utc_timestamp: ISODate("2014-09-15T04:59:19.431Z"),
type: "emailed"
},
{
utc_timestamp: ISODate("2014-09-15T04:58:19.431Z"),
type: "clicked"
},
],
...
}
How do I get the count of log entries of type "clicked" from this month, only if there is not a log entry of type "emailed" this month?
In other words, I want to find out which clicks have not been sent a related email.
So, in this example, the count would be 1 since the most recent "clicked" entry doesn't have an "emailed" entry.
Note: For this use case, clicks don't have unique IDs - this is all the data that is logged.
ListFieldand I simply append a dictionary to it.