>>> user.save() # save() returns the number of rows modified.
>>> user.id
>>> user.save()
>>> user.id
>>> huey.save()
>>> huey.id
如果你更新多个记录,使用UPDATE插询。下列例子将更新Tweet多个满足如果是昨天之前发表的实例,将它们标示为已发表,Model.update()接受关键字参数,这些
关键字个模型的字段一一对应。
>>> today = datetime.today() >>> query = Tweet.update(is_published=True).where(Tweet.creation_date < today) >>> query.execute() # Returns the number of rows that were updated. 4