Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET /works: omit id-less works #946

Open
lautarodragan opened this issue Jul 2, 2019 · 0 comments
Open

GET /works: omit id-less works #946

lautarodragan opened this issue Jul 2, 2019 · 0 comments
Labels

Comments

@lautarodragan
Copy link
Member

const getByFilters = async (worksFilters: WorksFilters = {}): Promise<WorksWithCount> => {
workControllerLogger.trace({ method: 'getByFilters', worksFilters }, 'Getting Work by Filters from DB')
const { offset, limit, ...filters } = worksFilters
const works = await collection
.find(filters, { projection: { _id: false } })
.sort({ _id: -1 })
.skip(offset)
.limit(limit || 10)
.toArray()
const count = await collection.find(filters, { projection: { _id: false } }).count()
return { count, works }
}

Update .find(filters, { projection: { _id: false } }) to something like

.find({ ...filters, id: { $exists: true } }, { projection: { _id: false } })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant