Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
commons
python-commons
Commits
8d6aab9a
Commit
8d6aab9a
authored
Aug 30, 2016
by
Ryan Berkheimer
Browse files
updated comments to be more instructive (mongo_remove_one, mongo_remove_many)
parent
5eaf993e
Changes
1
Hide whitespace changes
Inline
Side-by-side
python_commons/db_utils.py
View file @
8d6aab9a
...
...
@@ -136,23 +136,29 @@ def mongo_replace_one(collection, record, argument):
def
mongo_remove_one
(
collection
,
record
):
""" Removes a single specified record from the specified collection.
""" Removes a single specified record from the specified collection, using
the given record (Argument). For example, the record could be an entire record,
just an id, or another key value argument. This will remove the first matching
record with the given argument. Returns the number of records removed.
"""
try
:
return
collection
.
delete_one
(
record
)
deletion
=
collection
.
delete_one
(
record
)
return
deletion
.
deleted_count
except
:
print
'Could not remove record'
return
False
return
0
def
mongo_remove_many
(
collection
,
record
):
""" Removes a single specified record from the specified collection.
""" Removes all documents in the given collection with the given record (argument).
For example, the record could be an entire record,
just an id, or another key value argument. This will remove all matching
records with the given argument.
"""
try
:
return
collection
.
delete_many
(
record
)
deletion
=
collection
.
delete_many
(
record
)
return
deletion
.
deleted_count
except
:
print
'Could not remove records'
return
False
return
0
def
mongo_update_one
(
collection
,
argument
,
update
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment