FIX: Bugs
This commit is contained in:
@@ -4,25 +4,30 @@ const { client } = require('../../setup/typesense')
|
||||
const TsApiFeatures = require("../../utils/TsApiFeatures");
|
||||
|
||||
const getAllBelongings = async () => {
|
||||
return Belonging.find({}, null, null)
|
||||
return Belonging.find({}, null, null).populate('category')
|
||||
}
|
||||
|
||||
const createBelonging = async (data) => {
|
||||
console.log(data)
|
||||
return Belonging.create(data, null)
|
||||
}
|
||||
|
||||
const getBelonging = async (belongingId) => {
|
||||
const belonging = await Belonging.findById(belongingId, null, null).lean()
|
||||
let belonging = await Belonging.findById(belongingId, null, null)
|
||||
|
||||
if (!belonging) {
|
||||
throw new AppError('NoBelongingFound', 404, {})
|
||||
}
|
||||
|
||||
const documentUrls = await belonging.getDocumentsSignedUrls()
|
||||
const imageUrls = await belonging.getImagesSignedUrls()
|
||||
const mainImageUrls = await belonging.getMainImagedSignedUrl()
|
||||
|
||||
belonging.signedDocumentUrls = belonging.getDocumentsSignedUrls()
|
||||
belonging.signedImageUrls = belonging.getImagesSignedUrls()
|
||||
belonging.signedMainImageUrls = belonging.getMainImagedSignedUrl()
|
||||
belonging = JSON.parse(JSON.stringify(belonging))
|
||||
|
||||
belonging.signedDocumentUrls = documentUrls
|
||||
belonging.signedImageUrls = imageUrls
|
||||
belonging.signedMainImageUrls = mainImageUrls
|
||||
|
||||
|
||||
return belonging
|
||||
@@ -127,4 +132,4 @@ const getTypeSenseSchema = () => {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {indexAllBelongings, getBelonging, getAllBelongings, createBelonging, deleteBelonging, searchBelongings}
|
||||
module.exports = {updateBelonging, indexAllBelongings, getBelonging, getAllBelongings, createBelonging, deleteBelonging, searchBelongings}
|
||||
Reference in New Issue
Block a user