我想从烧瓶中返回一个自定义属性,例如
class Item(db.Model):
creator_id = db.Column(db.Integer, db.ForeignKey('User.id'))
owner_id = db.Column(db.Integer, db.ForeignKey('User.id'))
owner = db.relationship("User",backref="items",primary_join="Item.owner_id==User.id")
owner = db.relationship("User",backref="created_items",primary_join="Item.creator_id==User.id")
class User(db.Model):
id = db.Column(db.Integer, primary_key = True)
firstName = db.Column(db.Unicode(50), nullable = False)
lastName = db.Column(db.Unicode(50), nullable = False)
email = db.Column(db.Unicode(100), nullable = False)
我希望能够在 /api/User/1 中为创建者的项目中返回 firstName + " " + lastName 以用于烧瓶休息