ADD: updateInputQuery logic
This commit is contained in:
@@ -67,12 +67,25 @@ const ensureCollectionExists = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const searchBelongings = async (inputQuery) => {
|
const searchBelongings = async (inputQuery) => {
|
||||||
|
inputQuery = updateInputQuery(inputQuery, {})
|
||||||
|
|
||||||
const tsFeatures = new TsApiFeatures(client, 'belongings', inputQuery).filter().facet().sort().limitFields().paginate().search()
|
const tsFeatures = new TsApiFeatures(client, 'belongings', inputQuery).filter().facet().sort().limitFields().paginate().search()
|
||||||
|
|
||||||
let { facets, items, totalCount, pagesCount } = await tsFeatures.execute()
|
let { facets, items, totalCount, pagesCount } = await tsFeatures.execute()
|
||||||
|
|
||||||
return { facets, belongings: items, totalCount, pagesCount }
|
return { facets, belongings: items, totalCount, pagesCount }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateInputQuery = (inputQuery, extraQueries, features) => {
|
||||||
|
for (const [key, value] of Object.entries(extraQueries)) {
|
||||||
|
inputQuery[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
inputQuery.query_by = 'name,unit,tags,description,_id'
|
||||||
|
|
||||||
|
return inputQuery
|
||||||
|
}
|
||||||
|
|
||||||
const indexAllBelongings = async () => {
|
const indexAllBelongings = async () => {
|
||||||
const batchSize = 20
|
const batchSize = 20
|
||||||
const count = await Belonging.countDocuments({}, null)
|
const count = await Belonging.countDocuments({}, null)
|
||||||
|
|||||||
Reference in New Issue
Block a user