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
We want to find the data and sort them in two ways:
by text and then by number -> (a, 1), (a, 2), (b, 1), (b, 2)
by number and then by text -> (a, 1), (b, 1), (a, 2), (b, 2)
While this is possible in Mongo (.sort({ text: 1, number: 1 }) vs .sort({ number: 1, text: 1 })), it is not possible in vibe.d. The reason is that Mongo respects order of fields in an object passed to sort(), while D's associative arrays don't preserve key order.
As the one with design flaw is actually Mongo (as I guess that in BSON as in JSON key order should not be relevant for objects), probably a non-stantard API should be created to enable such sorts.
The text was updated successfully, but these errors were encountered:
Let's assume we have collection with the following data:
We want to find the data and sort them in two ways:
While this is possible in Mongo (
.sort({ text: 1, number: 1 })
vs.sort({ number: 1, text: 1 })
), it is not possible in vibe.d. The reason is that Mongo respects order of fields in an object passed tosort()
, while D's associative arrays don't preserve key order.As the one with design flaw is actually Mongo (as I guess that in BSON as in JSON key order should not be relevant for objects), probably a non-stantard API should be created to enable such sorts.
The text was updated successfully, but these errors were encountered: