UPDATE: line in indexAllBelongings, collection name to belongings

This commit is contained in:
MohammadHMazarei
2025-04-22 12:58:25 +03:30
parent 1ae70dda18
commit 5ce201c4e4
+5 -8
View File
@@ -1,7 +1,7 @@
const Belonging = require('./belongingModel')
const AppError = require('../../globalErrorHandler/AppError')
const { client } = require('../../setup/typesense')
const TsApiFeatures = require("../../utils/TsApiFeatures");
const TsApiFeatures = require('../../utils/TsApiFeatures')
const getAllBelongings = async () => {
return Belonging.find({}, null, null).populate('category')
@@ -29,7 +29,6 @@ const getBelonging = async (belongingId) => {
belonging.signedImageUrls = imageUrls
belonging.signedMainImageUrls = mainImageUrls
return belonging
}
@@ -92,28 +91,26 @@ const indexAllBelongings = async () => {
let documents = []
for (const belonging of belongings) {
const data = {
_id: belonging._id,
isActive: belonging.isActive,
belongingCode: belonging.belongingCode,
category: belonging.category.map( x=> x.englishName),
nativeCategory: belonging.category.map( x=> x.nativeName),
category: belonging.category.map((x) => x.englishName),
nativeCategory: belonging.category.map((x) => x.nativeName),
documents: belonging.documents,
description: belonging.description,
coordinates: belonging.location.coordinates
coordinates: belonging.location.coordinates,
}
documents.push(data)
}
await client.collections('belonging').documents().import(documents, {action: 'emplace'})
await client.collections('belongings').documents().import(documents, { action: 'emplace' })
}
return { totalCount: count }
}
const getTypeSenseSchema = () => {
return {
name: 'belongings',