1.sqlalchemy object序列化为json
posts = Post.query.all()
serializer = Serializer(posts,many=True)
data = serializer.data
2.像django orm一样使用sqlalchemy
posts = Post.query.filter_by(id__in=['1','2','3'],tags__name='sqlalchemy').order_by('-id').all()
3.去掉一些sqlalchemy的重复工作
# 关联用户表
class Post(ModelUserMixin, Model):
user_related_name = 'posts'
titile = ...
地址:https://github.com/honmaple/maple-json
代码很简单,没写注释应该也能看懂,感觉不错,所以分享出来一下