Skip to content

Commit e5b0d82

Browse files
authored
Merge pull request #7 from alexpantyukhin/add_first_last
add first and last handling
2 parents 29c558e + 10a1b1b commit e5b0d82

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

graphene_mongo/fields.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,18 @@ def fields(self):
8181

8282
@classmethod
8383
def get_query(cls, model, info, **args):
84+
objs = model.objects()
8485
if args:
85-
return model.objects().filter(**args)
86-
return model.objects()
86+
first = args.pop('first', None)
87+
last = args.pop('last', None)
88+
objs = objs.filter(**args)
89+
90+
if first is not None:
91+
objs = objs[:first]
92+
if last is not None:
93+
objs = objs[:-last]
94+
95+
return objs
8796

8897
@classmethod
8998
def merge_querysets(cls, default_queryset, queryset):

0 commit comments

Comments
 (0)