Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions django_mongodb_engine/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ def fetch(self, low_mark, high_mark):

@safe_call
def count(self, limit=None):
results = self.get_cursor()
if limit is not None:
results.limit(limit)
return results.count()
if(self.mongo_query):
return self.collection.count_documents(self.mongo_query)
return self.collection.estimated_document_count()
#results = self.get_cursor()
#if limit is not None:
# results.limit(limit)
#return results.count()

@safe_call
def order_by(self, ordering):
Expand All @@ -129,7 +132,7 @@ def order_by(self, ordering):
@safe_call
def delete(self):
options = self.connection.operation_flags.get('delete', {})
self.collection.remove(self.mongo_query, **options)
self.collection.delete_many(self.mongo_query, **options)

def get_cursor(self):
if self.query.low_mark == self.query.high_mark:
Expand Down
6 changes: 3 additions & 3 deletions django_mongodb_engine/south_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def add_column(self, table_name, field_name, field, keep_default=True):
db_prep_save = field.get_db_prep_save(default, connection=connection)
default = connection.ops.value_for_db(db_prep_save, field)
# Update all the documents that haven't got this field yet
collection.update({name: {'$exists': False}},
collection.update_many({name: {'$exists': False}},
{'$set': {name: default}})
if not keep_default:
field.default = NOT_PROVIDED
Expand All @@ -53,11 +53,11 @@ def alter_column(self, table_name, column_name, field, explicit_name=True):

def delete_column(self, table_name, name):
collection = self._get_collection(table_name)
collection.update({}, {'$unset': {name: 1}})
collection.update_many({}, {'$unset': {name: 1}})

def rename_column(self, table_name, old, new):
collection = self._get_collection(table_name)
collection.update({}, {'$rename': {old: new}})
collection.update_many({}, {'$rename': {old: new}})

def create_unique(self, table_name, columns, drop_dups=False):
collection = self._get_collection(table_name)
Expand Down