コード例 #1
0
def get_results():
    epmongo = EPMongo()
    # epmongo = EPMongo(
    #     uri="mongodb://*****:*****@172.16.100.1:30001,172.16.100.11:30001,172.16.120.30:30001",
    #     db_name='epdb-prod')
    pipeline = generate_pipeline()
    results = epmongo.aggregate('products', pipeline)
    return results
コード例 #2
0
            "$unwind": {
                "path": "$position.group",
            }
        },
        {
            "$project": {
                "username": 1,
                "account": "$position.group.account"
            }
        },
    ]
    return pipeline


if __name__ == '__main__':
    epmongo = EPMongo()
    users = epmongo.get_docs_by_query('users',
                                      query=None,
                                      projection={'_id': 1})
    # print(c, users[0])
    # pipeline = generate_pipeline(users[0]['_id'])
    # docs = epmongo.aggregate('users', pipeline)
    # print(docs)
    # for each in docs:
    #     print(each)
    for each in users:
        pipeline = generate_pipeline(each['_id'])
        print(pipeline)
        for result in (epmongo.aggregate('users', pipeline)):
            print(result)