1

假设我有一堆带有字符串字段的记录。我现在想将一个常量字符串附加到该字段的每条记录。例如,我可能有“Wall”和“Page”作为字段值的记录,但如果我希望它们是“WallPost”和“PagePost”怎么办?我知道我可以循环浏览每条记录并单独更新它,但是有没有更好的方法来做到这一点(update_all我认为使用 )。谢谢!

4

1 回答 1

0

Well, if you need to append/prepend something to your string to every value, you will have to iterate through all values. The update_all doesn't let you get the self scope of each object, so i believe you will have to cycle and update.

于 2012-07-24T20:24:36.977 回答