Compare two date fields in MongoDB

前端 未结 6 1328
别跟我提以往
别跟我提以往 2020-12-10 04:36

in my collection each document has 2 dates, modified and sync. I would like to find those which modified > sync, or sync does not exist.

I tried

{\'m         


        
6条回答
  •  暖寄归人
    2020-12-10 05:32

    Right now your query is trying to return all results such that the modified field is greater than the word 'sync'. Try getting rid of the quotes around sync and see if that fixes anything. Otherwise, I did a little research and found this question. What you're trying to do just might not be possible in a single query, but you should be able to manipulate your data once you pull everything from the database.

提交回复
热议问题