Scott Dietrich
Scott Dietrich

Reputation: 686

Manually sort in a NoSQL db

I'm new to the NoSQL world and I'm wondering if there are some known good patterns established for maintaining a manually sorted list.

More specifically, imagine the typical ToDo list application. At the top you have the List and under that you have each of the Items. I want the end user to be able to drag and drop the items. Therefore, I need to preserve this order for the next time I read these Items.

In a Relational DB I had a few ways to solve this, though none of those ways were that pretty. Maybe there is something better in the world of NoSQL? Not that it should matter, I'm using Firebase.

Upvotes: 0

Views: 367

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317427

Just create an integer field for each item that indicates its position in the list. Update the values of the positions when user makes a change.

Upvotes: 3

Related Questions