redgeoff / delta-pouch

Conflict-free collaborative editing for PouchDB
196 stars 13 forks source link

Sortable IDs #5

Closed nolanlawson closed 10 years ago

nolanlawson commented 10 years ago

Saw this comment in the code:

// sort by createdAt as cannot guarantee that order preserved by pouch/couch

You could, if you created the IDs e.g. like this:

doc._id = doc.$id + '_' + doc.$createdAt.toJSON();

This would also give you the advantage that you could paginate in allDocs(), which would be good for performance because on big databases you don't want to have to read the whole thing into memory.