User LAST LOGIN stats

Get datetime of last successful login of each user – from logs collection

 

Count documents using Aggregation

Counts log entries,  with type equal 'CREATE’ , fetch patients data  from another collection,  remove empty documents (if patients was not found the field is empty array), count by provided user id.