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'
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')
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')
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')
def insert_one(bson): if mongodb_connect.connect() == True: result = mongodb_connect.getCol().insert_one(bson) print('insert success') else: print('insert fail')