Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ParsePy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ParsePy
Commits
ebcfa9c0
Commit
ebcfa9c0
authored
Jul 16, 2014
by
Roman Krejcik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query.exists() implemented using count, without fetching data. Added __len__
parent
4f7f66fe
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
parse_rest/query.py
+6
-5
No files found.
parse_rest/query.py
View file @
ebcfa9c0
...
...
@@ -101,6 +101,9 @@ class Queryset(object):
def
__iter__
(
self
):
return
iter
(
self
.
_fetch
())
def
__len__
(
self
):
return
self
.
_fetch
(
count
=
True
)
def
_fetch
(
self
,
count
=
False
):
"""
Return a list of objects matching query, or if count == True return
...
...
@@ -122,8 +125,7 @@ class Queryset(object):
attr
,
operator
=
Queryset
.
extract_filter_operator
(
name
)
if
operator
is
None
:
self
.
_where
[
attr
]
=
parse_value
else
:
if
operator
==
'relatedTo'
:
elif
operator
==
'relatedTo'
:
self
.
_where
[
'$'
+
operator
]
=
parse_value
else
:
try
:
...
...
@@ -140,11 +142,10 @@ class Queryset(object):
return
self
def
count
(
self
):
return
self
.
_fetch
(
count
=
True
)
return
len
(
self
)
def
exists
(
self
):
results
=
self
.
_fetch
()
return
len
(
results
)
>
0
return
bool
(
self
)
def
get
(
self
):
results
=
self
.
_fetch
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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