I am using the withQuery of grapher-react (https://github.com/cult-of-coders/grapher-react) to fetch data.
The query is like below
const userData = {
_id: 1,
profile: {
firstName: 1,
lastName: 1,
phoneNumber: 1
},
shortName: 1,
cookies: 1,
}
const tutorUserData = {
_id: 1,
profile: {
headline: 1,
hourlyRate: 1,
firstName: 1,
lastName: 1,
croppedPicture: 1,
tag: 1,
currency: 1,
subjects: 1,
phoneNumber: 1
},
shortName: 1,
cookies: 1,
}
export default Packages.createQuery('packages', {
ownerId: 1,
owner: userData,
creatorId: 1,
creator: tutorUserData,
cost: 1,
createdAt: 1,
expiryDate: 1,
currency: 1,
values: 1,
$filters: {
expiryDate: { $gt: new Date() },
'values.remainingMinutes': { $gt: 0 }
},
$options: {
sort: {
createdAt: -1
}
},
$filter({ filters, options, params }) {
if (params.filters) {
Object.keys(params.filters).forEach(key => {
filters[key] = params.filters[key]
})
}
if (params.options) {
Object.keys(params.options).forEach(key => {
options[key] = params.options[key]
})
}
}
})
The code of withQuery:
withQuery(
({ otherUser, user, params }) => {
return query.clone({
...params,
filters: {
$and: [{ ownerId: user._id }, { creatorId: otherUser._id }]
},
options: {
limit: 3,
sort: { 'values.pending': -1, createdAt: -1 }
}
})
},
{ reactive: true }
)(Component)
And the result of creator data: result
I am sure the creator's profile have many fields other than the result in database.
Does anyone have any ideas about why I the result like that?