假设我的数据模型:
class Book(Model):
id = PrimaryKeyField()
title = CharField(max_length=64, unique=True)
author = CharField(max_length=64)
publisher = CharField(max_length=64)
price = DecimalField(max_digits=10, decimal_places=2)
desc = CharField(max_length=256)
如果我要根据条件更新的话, 找了很多文档基本都是:
Book.update({Book.price: 29.9}).where(Book.author == '鲁迅')
但外部调用的话只能提供字段名比如 {'price': 29.9}, {'author': '鲁迅'}, 怎样才能拼出上边的语句?