We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I've got currently 30 messages stored in mongodb and it seems that they are sorted mostly* by mongo internal _id field and not by date.
* take a look at _id of first message
Here is sample:
> db.messages.find({},{created:1}) { "_id" : ObjectId("54b8e23dae8939e356b486f4"), "created" : ISODate("2015-01-16T10:04:45.464Z") } { "_id" : ObjectId("54aceb9001f053f503b6d55f"), "created" : ISODate("2015-01-07T08:17:20.012Z") } { "_id" : ObjectId("54aceb9101f053f503b6d560"), "created" : ISODate("2015-01-07T08:17:21.867Z") } { "_id" : ObjectId("54b8c4f0ae8939e356b486ed"), "created" : ISODate("2015-01-16T07:59:44.244Z") } { "_id" : ObjectId("54b8c4f1ae8939e356b486ee"), "created" : ISODate("2015-01-16T07:59:45.373Z") } { "_id" : ObjectId("54b8d3c7ae8939e356b486ef"), "created" : ISODate("2015-01-16T09:03:03.230Z") } { "_id" : ObjectId("54b8d3c8ae8939e356b486f0"), "created" : ISODate("2015-01-16T09:03:04.200Z") } { "_id" : ObjectId("54b8deb7ae8939e356b486f1"), "created" : ISODate("2015-01-16T09:49:43.142Z") } { "_id" : ObjectId("54b8deb8ae8939e356b486f2"), "created" : ISODate("2015-01-16T09:49:44.160Z") } { "_id" : ObjectId("54b8e23dae8939e356b486f3"), "created" : ISODate("2015-01-16T10:04:45.385Z") } { "_id" : ObjectId("54bcc3834a22d404b713168c"), "created" : ISODate("2015-01-19T08:42:43.207Z") } { "_id" : ObjectId("54bcc3844a22d404b713168d"), "created" : ISODate("2015-01-19T08:42:44.352Z") } { "_id" : ObjectId("54bcd8904a22d404b713168e"), "created" : ISODate("2015-01-19T10:12:32.014Z") } { "_id" : ObjectId("54bcd8904a22d404b713168f"), "created" : ISODate("2015-01-19T10:12:32.940Z") } { "_id" : ObjectId("54bd10684a22d404b7131690"), "created" : ISODate("2015-01-19T14:10:47.995Z") } { "_id" : ObjectId("54bd10684a22d404b7131691"), "created" : ISODate("2015-01-19T14:10:48.887Z") } { "_id" : ObjectId("54bd10f64a22d404b7131692"), "created" : ISODate("2015-01-19T14:13:10.700Z") } { "_id" : ObjectId("54bd10f74a22d404b7131693"), "created" : ISODate("2015-01-19T14:13:11.621Z") } { "_id" : ObjectId("54cb66fab2c2f2eb6bfaa07a"), "created" : ISODate("2015-01-30T11:11:54.303Z") } { "_id" : ObjectId("54cb6821b2c2f2eb6bfaa07b"), "created" : ISODate("2015-01-30T11:16:49.296Z") } { "_id" : ObjectId("54dc743b78319c46012e3c10"), "created" : ISODate("2015-02-12T09:36:59.434Z") } { "_id" : ObjectId("54dc743b78319c46012e3c11"), "created" : ISODate("2015-02-12T09:36:59.582Z") } { "_id" : ObjectId("54c0c7a1bb2180ce176bec27"), "created" : ISODate("2015-01-22T09:49:21.261Z") } { "_id" : ObjectId("54c0c7a2bb2180ce176bec28"), "created" : ISODate("2015-01-22T09:49:22.768Z") } { "_id" : ObjectId("54c0c87bbb2180ce176bec29"), "created" : ISODate("2015-01-22T09:52:59.805Z") } { "_id" : ObjectId("54c0c87cbb2180ce176bec2a"), "created" : ISODate("2015-01-22T09:53:00.741Z") } { "_id" : ObjectId("54c0fe5dbb2180ce176bec2b"), "created" : ISODate("2015-01-22T13:42:53.476Z") } { "_id" : ObjectId("54c0fe5ebb2180ce176bec2c"), "created" : ISODate("2015-01-22T13:42:54.466Z") } { "_id" : ObjectId("54d1e5e3ebd97577889ba0c6"), "created" : ISODate("2015-02-04T09:26:59.673Z") } { "_id" : ObjectId("54d1e5e4ebd97577889ba0c7"), "created" : ISODate("2015-02-04T09:27:00.894Z") } > db.messages.find({},{created:1}).count() 30
However applying simple sort on created field is not that simple as mongo is crying about exceeding buffered data limit.
created
> db.messages.find({},{created:1}).sort({created:1}) error: { "$err" : "Runner error: Overflow sort stage buffered data usage of 34342473 bytes exceeds internal limit of 33554432 bytes", "code" : 17144 }
Creating additional index fixes that:
> db.messages.ensureIndex({created:1}) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 }
> db.messages.find({},{created:1}).sort({created:1}) { "_id" : ObjectId("54aceb9001f053f503b6d55f"), "created" : ISODate("2015-01-07T08:17:20.012Z") } { "_id" : ObjectId("54aceb9101f053f503b6d560"), "created" : ISODate("2015-01-07T08:17:21.867Z") } { "_id" : ObjectId("54b8c4f0ae8939e356b486ed"), "created" : ISODate("2015-01-16T07:59:44.244Z") } { "_id" : ObjectId("54b8c4f1ae8939e356b486ee"), "created" : ISODate("2015-01-16T07:59:45.373Z") } { "_id" : ObjectId("54b8d3c7ae8939e356b486ef"), "created" : ISODate("2015-01-16T09:03:03.230Z") } { "_id" : ObjectId("54b8d3c8ae8939e356b486f0"), "created" : ISODate("2015-01-16T09:03:04.200Z") } { "_id" : ObjectId("54b8deb7ae8939e356b486f1"), "created" : ISODate("2015-01-16T09:49:43.142Z") } { "_id" : ObjectId("54b8deb8ae8939e356b486f2"), "created" : ISODate("2015-01-16T09:49:44.160Z") } { "_id" : ObjectId("54b8e23dae8939e356b486f3"), "created" : ISODate("2015-01-16T10:04:45.385Z") } { "_id" : ObjectId("54b8e23dae8939e356b486f4"), "created" : ISODate("2015-01-16T10:04:45.464Z") } { "_id" : ObjectId("54bcc3834a22d404b713168c"), "created" : ISODate("2015-01-19T08:42:43.207Z") } { "_id" : ObjectId("54bcc3844a22d404b713168d"), "created" : ISODate("2015-01-19T08:42:44.352Z") } { "_id" : ObjectId("54bcd8904a22d404b713168e"), "created" : ISODate("2015-01-19T10:12:32.014Z") } { "_id" : ObjectId("54bcd8904a22d404b713168f"), "created" : ISODate("2015-01-19T10:12:32.940Z") } { "_id" : ObjectId("54bd10684a22d404b7131690"), "created" : ISODate("2015-01-19T14:10:47.995Z") } { "_id" : ObjectId("54bd10684a22d404b7131691"), "created" : ISODate("2015-01-19T14:10:48.887Z") } { "_id" : ObjectId("54bd10f64a22d404b7131692"), "created" : ISODate("2015-01-19T14:13:10.700Z") } { "_id" : ObjectId("54bd10f74a22d404b7131693"), "created" : ISODate("2015-01-19T14:13:11.621Z") } { "_id" : ObjectId("54c0c7a1bb2180ce176bec27"), "created" : ISODate("2015-01-22T09:49:21.261Z") } { "_id" : ObjectId("54c0c7a2bb2180ce176bec28"), "created" : ISODate("2015-01-22T09:49:22.768Z") } { "_id" : ObjectId("54c0c87bbb2180ce176bec29"), "created" : ISODate("2015-01-22T09:52:59.805Z") } { "_id" : ObjectId("54c0c87cbb2180ce176bec2a"), "created" : ISODate("2015-01-22T09:53:00.741Z") } { "_id" : ObjectId("54c0fe5dbb2180ce176bec2b"), "created" : ISODate("2015-01-22T13:42:53.476Z") } { "_id" : ObjectId("54c0fe5ebb2180ce176bec2c"), "created" : ISODate("2015-01-22T13:42:54.466Z") } { "_id" : ObjectId("54cb66fab2c2f2eb6bfaa07a"), "created" : ISODate("2015-01-30T11:11:54.303Z") } { "_id" : ObjectId("54cb6821b2c2f2eb6bfaa07b"), "created" : ISODate("2015-01-30T11:16:49.296Z") } { "_id" : ObjectId("54d1e5e3ebd97577889ba0c6"), "created" : ISODate("2015-02-04T09:26:59.673Z") } { "_id" : ObjectId("54d1e5e4ebd97577889ba0c7"), "created" : ISODate("2015-02-04T09:27:00.894Z") } { "_id" : ObjectId("54dc743b78319c46012e3c10"), "created" : ISODate("2015-02-12T09:36:59.434Z") } { "_id" : ObjectId("54dc743b78319c46012e3c11"), "created" : ISODate("2015-02-12T09:36:59.582Z") }
Due to bug #34 preferred way of sorting would be newest first, but some sorting buttons over message list would also do the trick.
The text was updated successfully, but these errors were encountered:
About mongo sorting when no sorting is defined: http://stackoverflow.com/a/11599283
Sorry, something went wrong.
mailhog/storage@153c814
Hopefully thats ok as a temporary fix - it ensures an index exists on created, and sorts them newest first to match the behaviour of in memory storage
but some sorting buttons over message list would also do the trick
I'll open another issue to improve it a bit 😄
No branches or pull requests
I've got currently 30 messages stored in mongodb and it seems that they are sorted mostly* by mongo internal _id field and not by date.
* take a look at _id of first message
Here is sample:
However applying simple sort on
created
field is not that simple as mongo is crying about exceeding buffered data limit.Creating additional index fixes that:
Due to bug #34 preferred way of sorting would be newest first, but some sorting buttons over message list would also do the trick.
The text was updated successfully, but these errors were encountered: