Discuss / Python / 关于github上面项目orm的删、改的一些问题

关于github上面项目orm的删、改的一些问题

Topic source
    async def update(self):
        args = list(map(self.getValue, self.__fields__))
        args.append(self.getValue(self.__primary_key__))
        rows = await execute(self.__update__, args)
        if rows != 1:
            logging.warn('failed to update by primary key: affected rows: %s' % rows)


    async def remove(self):
        args = [self.getValue(self.__primary_key__)]
        rows = await execute(self.__delete__, args)
        if rows != 1:
            logging.warn('failed to remove by primary key: affected rows: %s' % rows)

这样个orm更新和删除只能根据主键,那样子就不能根据where批量更改和删除

所以我觉得可以在model类里面加两个类方法,能执行批量删除与更新的


  • 1

Reply