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
It appears that if you create a new index with an array of fields, and then try to sort that collection by any field that is not at index 0, the query will break.
awaitdb.collection('example').createIndex(['createdAt','example'])awaitdb.collection('example').insert({example: 1,createdAt: newDate()})awaitdb.collection('example').insert({example: 2,createdAt: newDate()})awaitdb.collection('example').insert({example: 3,createdAt: newDate()})constdocs1=awaitdb.collection('example').find().sort('createdAt',-1)// Worksconstdocs2=awaitdb.collection('example').find().sort('example',-1)// This does not work
The text was updated successfully, but these errors were encountered:
Sadly, that's a limitation of how B+ trees and indexes work and is by design. You can't sort by a field that isn't at index 0 because the B+ tree only sorts by the prefix of the key. If there are other fields you need to sort them by then you'll need to have more indexes. 😁
It appears that if you create a new index with an array of fields, and then try to sort that collection by any field that is not at index 0, the query will break.
The text was updated successfully, but these errors were encountered: