On 22 January 2013 10:44, Alex <a...@sicanstudios.com> wrote: > Hi, > I’m trying to get the previous and next item (articles) from a database > with Datamapper. I thought of doing it with the serial identifier > > property :id, Serial > > > and increment/decrease this number to find the previous/next posts of that > particular article, but it doesn’t work. Because the serial is incremented > fine for new articles (1,2,3,4,5), but if you delete say id: #3, then the > next article of #2 will be #4, not #3. > > Do you know if there is an easier/more correct way to do it with > Datamapper? >
Hey Alex, Sounds like you're missing a concept in your application. Perhaps you should add some kind of ordering/page column to your table if you need to be explicit about ordering? This way you could rearrange the ordering if necessary, ensure uniqueness for pages/ordering and other goodness. Alternatively, if you're storing created_at timestamps on your tables you could use this as a surrogate for ordering. Cheers, Ben -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.