Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT2810 H21
Team 28
project-3
Commits
fd379ac3
Commit
fd379ac3
authored
Oct 31, 2021
by
DESKTOP-J7QTMBR\mikke
Browse files
filter sorter and more
parent
cee0197b
Changes
2
Hide whitespace changes
Inline
Side-by-side
project-3/backend/src/resolver.js
View file @
fd379ac3
...
...
@@ -5,12 +5,18 @@ module.exports = {
country
:
async
(
args
)
=>
{
try
{
let
kontinent
=
String
(
args
.
continent_contains
||
""
)
//
let
query = filter ? {$or: buildFilters(resolvers)} : {};
let
search
=
String
(
args
.
search
||
""
)
sortOrder
=
{};
//if(args.sort !== void 0){
sortOrder
=
{
capital
:
-
1
};
const
countryFetched
=
await
Country
.
find
({
continent
:
{
$in
:
kontinent
}})
if
(
args
.
order
!==
null
){
sortOrder
=
{
capital
:
(
args
.
order
===
"
ASC
"
?
1
:
-
1
)};
}
let
start
=
parseInt
(
args
.
start
||
0
);
let
limit
=
parseInt
(
args
.
limit
||
-
1
);
const
countryFetched
=
await
Country
.
find
({
continent
:
{
$regex
:
kontinent
,
'
$options
'
:
'
i
'
},
name
:
{
$regex
:
search
,
'
$options
'
:
'
i
'
}})
.
limit
(
limit
===
-
1
?
'
$count
'
:
limit
)
.
skip
(
start
)
.
sort
(
sortOrder
);
return
countryFetched
.
map
((
country
)
=>
{
return
{
...
...
project-3/backend/src/schema.js
View file @
fd379ac3
...
...
@@ -17,7 +17,7 @@ module.exports = buildSchema(`
capital: String!
}
type Query {
country(continent_contains: String, s
kip
: Int,
take
: Int, order: String): [Country!]
country(continent_contains: String, s
tart
: Int,
limit
: Int, order:
String, search:
String): [Country!]
}
input NameOrder {
nameOrder: String
...
...
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