Example #1
0
def find(where=None, projection=None):
    if mongodb_connect.connect() == True:
        results = mongodb_connect.getCol().find(where, projection)
        print('find', results.count(), 'documents')
        return results
    else:
        print('find fail')
def delete_one(bson):
    if mongodb_connect.connect() == True:
        result = mongodb_connect.getCol().delete_one(bson)
        print('delete success')
        return 'success'
    else:
        print('delete fail')
        return 'fail'
Example #3
0
def find_one(where=None, projection=None):
    if mongodb_connect.connect() == True:
        result = mongodb_connect.getCol().find_one(where, projection)
        return result
    else:
        print('find fail')
Example #4
0
def update_one(where, value):
    if mongodb_connect.connect() == True:
        result = mongodb_connect.getCol().update_one(where, value)
        print('update success')
    else:
        print('update fail')
Example #5
0
def update_many(where, value):
    if mongodb_connect.connect() == True:
        result = mongodb_connect.getCol().update_many(where, value)
        print('update success', result.modified_count, 'documents')
    else:
        print('update fail')
def delete_many(bson={}):
    if mongodb_connect.connect() == True:
        result = mongodb_connect.getCol().delete_many(bson)
        print('delete success')
    else:
        print('delete fail')
Example #7
0
def insert_one(bson):
    if mongodb_connect.connect() == True:
        result = mongodb_connect.getCol().insert_one(bson)
        print('insert success')
    else:
        print('insert fail')