Member 12310790 Ответов: 0

Сортировка закрытой коллекции mongodb в spring boot


I am trying to sort capped collection in descending order.

what I have tried:

    @Query(sort = "{$natural:-1}")
    Flux<Message> findAllByConversationId(String conversationId);

it gives:

Query failed with error code 2 and error message cannot use tailable option with a sort other than {$natural: 1}'

but when I use this query in robo3t:

db.getCollection('message').find({}).sort({$natural:-1})
it works fine !

any help ?

What I have tried:

<pre>what I have tried:

    @Query(sort = "{$natural:-1}")
    Flux<Message> findAllByConversationId(String conversationId);

it gives:

Query failed with error code 2 and error message cannot use tailable option with a sort other than {$natural: 1}'

but when I use this query in robo3t:

db.getCollection('message').find({}).sort({$natural:-1})
it works fine !

0 Ответов