try this gem http://github.com/sam/dm-more/tree/master/dm-adjust
YourModel.all(:id => 1).adjust!(:counter => 1) On 11월13일, 오후4시32분, __andrew <[EMAIL PROTECTED]> wrote: > Hey All, > > I've recently switched from using ActiveRecord to DataMapper and the > minor differences have made it a smooth transition so far. However, I > can't seem to find any documentation on maintaining a counter. I have > an integer column in my model that needs to be incremented > periodically. My first inclination was to use model.update_attributes > (), but this seems to be a bad idea because the database value could > be overwritten before DataMapper can write. The SQL query: > > UPDATE table_name SET counter = counter + 1 WHERE id = n; > > accomplishes what I want to do. I've perused the DataMapper code and > docs, but I can't seem to find a method that will abstract this. > ActiveRecord's is called 'increment_counter'. Am I missing the simple > way to do this? > > Andrew S. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
