You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not supported, you should store a lastMessageTimestamp in chat schema if you want to sort chats by the last message timestamp. That approach is much more performant because you can use indexes.
Originally asked on Stack Overflow.
My MongoDB version 3.2, mongoose version is 4.6.0
These are my schemas:
I want to sort based on lastMessage's timestamp in a desc order. I tried these three
Also, no matter I use
-1
or1
,'desc'
, or 'asc'
fortimestamp
, it always gives me same results:The text was updated successfully, but these errors were encountered: