UPDATE: line in indexAllBelongings, collection name to belongings
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
const Belonging = require('./belongingModel')
|
const Belonging = require('./belongingModel')
|
||||||
const AppError = require('../../globalErrorHandler/AppError')
|
const AppError = require('../../globalErrorHandler/AppError')
|
||||||
const { client } = require('../../setup/typesense')
|
const { client } = require('../../setup/typesense')
|
||||||
const TsApiFeatures = require("../../utils/TsApiFeatures");
|
const TsApiFeatures = require('../../utils/TsApiFeatures')
|
||||||
|
|
||||||
const getAllBelongings = async () => {
|
const getAllBelongings = async () => {
|
||||||
return Belonging.find({}, null, null).populate('category')
|
return Belonging.find({}, null, null).populate('category')
|
||||||
@@ -29,7 +29,6 @@ const getBelonging = async (belongingId) => {
|
|||||||
belonging.signedImageUrls = imageUrls
|
belonging.signedImageUrls = imageUrls
|
||||||
belonging.signedMainImageUrls = mainImageUrls
|
belonging.signedMainImageUrls = mainImageUrls
|
||||||
|
|
||||||
|
|
||||||
return belonging
|
return belonging
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,28 +91,26 @@ const indexAllBelongings = async () => {
|
|||||||
let documents = []
|
let documents = []
|
||||||
|
|
||||||
for (const belonging of belongings) {
|
for (const belonging of belongings) {
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
_id: belonging._id,
|
_id: belonging._id,
|
||||||
isActive: belonging.isActive,
|
isActive: belonging.isActive,
|
||||||
belongingCode: belonging.belongingCode,
|
belongingCode: belonging.belongingCode,
|
||||||
category: belonging.category.map( x=> x.englishName),
|
category: belonging.category.map((x) => x.englishName),
|
||||||
nativeCategory: belonging.category.map( x=> x.nativeName),
|
nativeCategory: belonging.category.map((x) => x.nativeName),
|
||||||
documents: belonging.documents,
|
documents: belonging.documents,
|
||||||
description: belonging.description,
|
description: belonging.description,
|
||||||
coordinates: belonging.location.coordinates
|
coordinates: belonging.location.coordinates,
|
||||||
}
|
}
|
||||||
|
|
||||||
documents.push(data)
|
documents.push(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.collections('belonging').documents().import(documents, {action: 'emplace'})
|
await client.collections('belongings').documents().import(documents, { action: 'emplace' })
|
||||||
}
|
}
|
||||||
|
|
||||||
return { totalCount: count }
|
return { totalCount: count }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const getTypeSenseSchema = () => {
|
const getTypeSenseSchema = () => {
|
||||||
return {
|
return {
|
||||||
name: 'belongings',
|
name: 'belongings',
|
||||||
|
|||||||
Reference in New Issue
Block a user