Skip to content

Commit

Permalink
Version 1.2.1
Browse files Browse the repository at this point in the history
Merge pull request #25 from Djcharles26/work
  • Loading branch information
Djcharles26 authored Oct 30, 2021
2 parents 94f4d5c + 1d6fede commit 0543c3f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
7 changes: 1 addition & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
## Minor updates
- Added validation to avoid creating object if find result is none
## Major updates
- Added cursor const values in mongo_types
- Added argument to control parse of cursor in find methods
- Added tests to check correct work of parsed results
- Updated README.md
- Changed skip, limit and sort order in find when populate is not None
21 changes: 13 additions & 8 deletions pymongoose/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ def find(schema: str, query: dict, select = {}, populate=None, one=False, skip =
"$project": select
})

if(sort is not None):
aggregate.append({
"$sort": {
f"{sort_key}": sort_value
}
})

if(skip > 0):
aggregate.append({
"$skip": skip
Expand All @@ -317,13 +324,6 @@ def find(schema: str, query: dict, select = {}, populate=None, one=False, skip =
"$limit": limit
})

if(sort is not None):
aggregate.append({
"$sort": {
f"{sort_key}": sort_value
}
})


retval = database[schema_name].aggregate(aggregate)

Expand Down Expand Up @@ -421,7 +421,7 @@ def update(schema, query, update, many = False):
except:
raise MongoException(sys.exc_info()[0], message="Error updating document(s)", mongoError=MongoError.Bad_action)

def delete(schema, query, many = False):
def delete(schema, query, many = False, cascade=False):
"""
Delete documents inside collection
# Parameters
Expand All @@ -433,6 +433,9 @@ def delete(schema, query, many = False):
### many: bool
Variable to select if delete one ore many
defaults to: False
### cascade: bool
Variable to delete all items related with this object id
defaults to False
# Returns
------------
- number of documents deleted
Expand All @@ -445,6 +448,8 @@ def delete(schema, query, many = False):
retval = database[schema].delete_many(query)
return retval.deleted_count
else:
if(cascade):
id = database[schema].find_one(query, {"_id": 1})
database[schema].delete_one(query)
return 1
except:
Expand Down
4 changes: 2 additions & 2 deletions pymongoose/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PYMONGOOSE_VERSION = "1.2"
PYMONGOOSE_VERSION_NAME = "Version 1.2"
PYMONGOOSE_VERSION = "1.2.1"
PYMONGOOSE_VERSION_NAME = "Version 1.2.1"
PYMONGOOSE_VERSION_AUTHOR = "Juan Carlos Lara"

def pymongoose_version_print_full():
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pymongoose
version = 1.2
version = 1.2.1
author = Juan Carlos Lara
author_email = jlaraanaya@gmail.com
description = A pymongo helper with methods and classes
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
1.2.1

0 comments on commit 0543c3f

Please sign in to comment.