const Property = require('./propertyModel') const Land = require('./landModel') const Building = require('./buildingModel') const Category = require('../category/categoryModel') const PropertyStatus = require('../propertyStatus/propertyStatusModel') const chalk = require('chalk') const runSeeder = async () => { const buildingCategory = await Category.findOne({ englishName: 'Building' }) const lotCategory = await Category.findOne({ englishName: 'Lot' }) const availableStatus = await PropertyStatus.findOne({ englishName: 'available' }) const inReviewStatus = await PropertyStatus.findOne({ englishName: 'in_review' }) const reservedStatus = await PropertyStatus.findOne({ englishName: 'reserved' }) const sampleProperties = [ { name: 'مجتمع اداری تجاری نگین الهیه', propertyType: 'Building', category: buildingCategory?._id, status: availableStatus?._id, nationalGeoCode: '537123395123439', description: 'مجتمع اداری ۱۰ طبقه با دسترسی عالی به بزرگراه صدر و مترو', dong: 6, ownerName: 'شرکت سرمایه‌گذاری پارس', registrationPlate: '۱۲۳۴/۵۶', uniqueId: '140201123456789012', serialNumber: 'A/987654', zoningType: 'تجاری - اداری', address: 'تهران، الهیه، خیابان فرشته، پلاک ۱۲', postalCode: '1965834211', location: { type: 'Point', coordinates: [51.4235, 35.7952], // [lng, lat] }, tags: ['اداری', 'الهیه', 'مدرن', 'سند تک‌برگ'], isActive: true, }, { name: 'زمین ویلایی شهرک غرب فاز ۴', propertyType: 'Land', category: lotCategory?._id, status: availableStatus?._id, nationalGeoCode: '536987394852139', description: 'زمین دو کله با بر ۲۵ متر و دستور نقشه ۵ طبقه مسکونی', dong: 6, ownerName: 'محسن رضایی', registrationPlate: '۴۵۶۷/۸۹', uniqueId: '140202234567890123', serialNumber: 'B/123456', zoningType: 'مسکونی', address: 'تهران، شهرک غرب، فاز ۴، خیابان فلامک شمالی', postalCode: '1467893214', location: { type: 'Point', coordinates: [51.3712, 35.7725], }, tags: ['زمین', 'شهرک غرب', 'دو کله'], isActive: true, }, { name: 'برج مسکونی یاس نیاوران', propertyType: 'Building', category: buildingCategory?._id, status: reservedStatus?._id || availableStatus?._id, nationalGeoCode: '539145395412039', description: 'واحد ۳۰۰ متری طبقه ۸ با ویوی ابدی کاخ نیاوران و ۳ پارکینگ سندی', dong: 6, ownerName: 'سارا صادقی', registrationPlate: '۷۸۹۰/۱۲', uniqueId: '140203345678901234', serialNumber: 'C/654321', zoningType: 'مسکونی', address: 'تهران، نیاوران، خیابان باهنر، کوچه یاس', postalCode: '1978945612', location: { type: 'Point', coordinates: [51.4678, 35.8156], }, tags: ['لوکس', 'نیاوران', 'پنت‌هاوس'], isActive: true, }, { name: 'باغ ویلای قصرالدشت شیراز', propertyType: 'Land', category: lotCategory?._id, status: availableStatus?._id, nationalGeoCode: '645123328456139', description: 'باغ ۲۰۰۰ متری با درختان کهنسال و عمارت دوبلکس ۴۰۰ متری', dong: 6, ownerName: 'علیرضا زندی', registrationPlate: '۳۲۱۴/۵۶', uniqueId: '140204456789012345', serialNumber: 'D/789123', zoningType: 'باغ ویلا', address: 'شیراز، قصرالدشت، خیابان وکلا، کوچه ۱۲', postalCode: '7198765432', location: { type: 'Point', coordinates: [52.4823, 29.6412], }, tags: ['شیراز', 'باغ', 'قصرالدشت'], isActive: true, }, { name: 'ملک تجاری چهارباغ عباسی اصفهان', propertyType: 'Building', category: buildingCategory?._id, status: inReviewStatus?._id || availableStatus?._id, nationalGeoCode: '584123361456239', description: 'مغازه تجاری دو دهنه بر خیابان اصلی چهارباغ با سند شش دانگ ملکیت', dong: 6, ownerName: 'محمد مهدی اصفهانی', registrationPlate: '۹۶۳۲/۱۴', uniqueId: '140205567890123456', serialNumber: 'E/456789', zoningType: 'تجاری', address: 'اصفهان، خیابان چهارباغ عباسی، جنب سینما سپاهان', postalCode: '8145678901', location: { type: 'Point', coordinates: [51.6685, 32.6546], }, tags: ['اصفهان', 'تجاری', 'چهارباغ'], isActive: true, }, ] await Property.deleteMany({}) console.log(chalk.red('Deleted all property records.')) for (const propData of sampleProperties) { if (propData.propertyType === 'Building') { await Building.create(propData) } else if (propData.propertyType === 'Land') { await Land.create(propData) } else { await Property.create(propData) } } console.log( chalk.green.bold( `PROPERTIES: Created ${sampleProperties.length} sample property(ies)` ) ) } module.exports = { runSeeder }