开发者社区> 问答> 正文

mongodb 使用问题,封装后查询无结果

pymongo 封装如下,利用module特性实现单例模式。
1
2
3
4
下面是测试代码
5
上面2中方法使用的查询参数以及查询的库都一致,一个能够查询到结果,一个却不能
求解或。

展开
收起
落地花开啦 2016-02-19 10:59:06 3060 0
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人

    `def _check_collection(method):

    ''' Decorate mehtod to validate collection arguments '''
    @functools.wraps(method)
    def wrapped(self, collection, **kwargs):
        if collection not in self.COLLECTIONS:
            # logger.error('%s not in permit collections tuple', table)
           raise HTTPError(500, 'Internal server error')
        return method(self, collection, **kwargs)
    return wrapped`

    装饰器忘记调用 db 操作方法了。

    2019-07-17 18:44:26
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Data as a Service - 数据即服务 -- MongoDB⾼级应⽤模式 立即下载
阿里云MongoDB云服务构建 立即下载
饿了么高级架构师陈东明:MongoDB是如何逐步提高可靠性的 立即下载