Hello,
I’d like to create a good schema that allows a fast change of the (sort) order - the client should be able to add, remove and rearrange the order of the document(s) within a group (perhaps with a group identifier or set).
Also every single document can get often called directly by it’s ID - and only this data is needed, not the complete group.
It’s recommend to return the current order index with each single document.
Using a key {…, order: 1} for every document in the group results in updating every single document with a new query (I am new to mongoDB - please correct me if I am wrong) to change and/or increment the order value.
Or using a set [‘id1’, ‘id2’, …] or just inserting the whole document (they aren’t big - this post has nearly the same size ;-)) in this set.
Not sure what’s the best solution and how to update this data.
Also I think I will have limit the group size for example to 999 items. But this is open and will depend on the performance.
Thanks for your help!