feat(property): convert registrationDate to Date object and add Jalali utilities
deploy-chabokan / deploy (push) Canceled after 0s
deploy-chabokan / deploy (push) Canceled after 0s
This commit is contained in:
@@ -57,7 +57,7 @@ const propertySchema = new mongoose.Schema(
|
||||
serialNumber: String, // شماره سریال چاپی سند
|
||||
provinceRegistry: String,
|
||||
localRegistryOffice: String,
|
||||
registrationDate: String, // تاریخ ثبت سند
|
||||
registrationDate: Date, // تاریخ ثبت سند (MongoDB Date object)
|
||||
|
||||
// Owner Specifications (مشخصات مالک)
|
||||
ownerName: String,
|
||||
|
||||
@@ -5,6 +5,7 @@ const AppError = require('../../globalErrorHandler/AppError')
|
||||
const { client } = require('../../setup/typesense')
|
||||
const TsApiFeatures = require('../../utils/TsApiFeatures')
|
||||
const { moveFromTempToMain, getSignedUrl } = require('../file/fileService')
|
||||
const { normalizeToDate } = require('../../utils/jalali')
|
||||
|
||||
const getAllProperties = async () => {
|
||||
return Property.find({}, null, null).populate('category').populate('status')
|
||||
@@ -18,6 +19,10 @@ const createProperty = async (data) => {
|
||||
data.documentUrls = await moveFromTempToMain(data.documentUrls, 'documents')
|
||||
}
|
||||
|
||||
if (data.registrationDate !== undefined) {
|
||||
data.registrationDate = normalizeToDate(data.registrationDate)
|
||||
}
|
||||
|
||||
if (data.propertyType === 'Land' || data.propertyType === 'زمین') {
|
||||
return Land.create(data)
|
||||
} else if (data.propertyType === 'Building' || data.propertyType === 'ساختمان') {
|
||||
@@ -52,6 +57,10 @@ const updateProperty = async (propertyId, data) => {
|
||||
data.documentUrls = await moveFromTempToMain(data.documentUrls, 'documents')
|
||||
}
|
||||
|
||||
if (data.registrationDate !== undefined) {
|
||||
data.registrationDate = normalizeToDate(data.registrationDate)
|
||||
}
|
||||
|
||||
const property = await Property.findOneAndUpdate({ _id: propertyId }, data, { new: true })
|
||||
|
||||
if (!property) {
|
||||
@@ -180,6 +189,7 @@ const searchPropertiesMongo = async (inputQuery = {}) => {
|
||||
registrationPlate: prop.registrationPlate || '',
|
||||
uniqueId: prop.uniqueId || '',
|
||||
serialNumber: prop.serialNumber || '',
|
||||
registrationDate: prop.registrationDate,
|
||||
coordinates: prop.location?.coordinates || [0, 0],
|
||||
location: prop.location,
|
||||
createdAt: Math.floor(new Date(prop.createdAt || Date.now()).getTime() / 1000),
|
||||
|
||||
Reference in New Issue
Block a user