Spaces:
Sleeping
Sleeping
| require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') }); | |
| const mongoose = require('mongoose'); | |
| const Product = require('./models/Product'); | |
| function _p(id, name, cat, sub, price, oldPrice, disc, sizes, colors, img, rat, rev, desc, stock, isNew, feat) { | |
| return { | |
| id, name, category: cat, subcategory: sub, price, oldPrice, discount: disc, sizes, colors, | |
| images: [img], image: img, rating: rat, reviews: rev, description: desc, inStock: stock, isNew, isFeatured: feat | |
| }; | |
| } | |
| const S = ["S", "M", "L", "XL"], SM = ["XS", "S", "M", "L", "XL"], ML = ["M", "L", "XL", "XXL"], SX = ["S", "M", "L", "XL", "XXL"], OS = ["One Size"]; | |
| const PRODUCTS = [ | |
| _p(1, "Klassik Biznes Ko'ylak", "kiyimlar", "Ko'ylaklar", 289000, 350000, 17, S, ["oq", "ko_k", "kulrang"], "https://images.unsplash.com/photo-1602810318383-e386cc2a3ccf?w=600&h=800&fit=crop", 4.8, 124, "Yuqori sifatli paxta matosidan tayyorlangan klassik biznes ko'ylak.", true, false, true), | |
| _p(2, "Premium Slim Fit Ko'ylak", "kiyimlar", "Ko'ylaklar", 345000, null, 0, SX, ["qora", "ko_k", "oq"], "https://images.unsplash.com/photo-1596755094514-f87e34085b2c?w=600&h=800&fit=crop", 4.6, 89, "Zamonaviy slim fit ko'ylak.", true, true, true), | |
| _p(3, "Qishki Issiq Kurtka", "kiyimlar", "Kurtkalar", 890000, 1100000, 19, ML, ["qora", "kulrang", "havorang"], "https://images.unsplash.com/photo-1544923246-77307dd270b5?w=600&h=800&fit=crop", 4.9, 256, "Sovuqdan himoya qiluvchi premium kurtka.", true, false, true), | |
| _p(4, "Sport Futbolka Pro", "kiyimlar", "Futbolkalar", 149000, 189000, 21, SM, ["qora", "oq", "ko_k", "qizil"], "https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?w=600&h=800&fit=crop", 4.5, 312, "Yuqori sifatli sport futbolka.", true, true, false), | |
| _p(5, "Elegant Blazer", "kiyimlar", "Blazerlar", 650000, null, 0, S, ["qora", "kulrang", "jigarrang"], "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=600&h=800&fit=crop", 4.7, 78, "Premium materialdan tayyorlangan elegant blazer.", true, false, true), | |
| _p(6, "Casual Polo Ko'ylak", "kiyimlar", "Ko'ylaklar", 195000, 240000, 19, S, ["oq", "ko_k", "yashil", "qizil"], "https://images.unsplash.com/photo-1625910513413-5fc68e7990a7?w=600&h=800&fit=crop", 4.4, 167, "Polo ko'ylak.", true, false, false), | |
| _p(7, "Denim Kurtka Classic", "kiyimlar", "Kurtkalar", 420000, null, 0, S, ["ko_k", "qora"], "https://images.unsplash.com/photo-1576995853123-5a10305d93c0?w=600&h=800&fit=crop", 4.6, 93, "Klassik denim kurtka.", true, true, false), | |
| _p(8, "Premium Hoodie", "kiyimlar", "Futbolkalar", 275000, 320000, 14, SX, ["qora", "kulrang", "havorang"], "https://images.unsplash.com/photo-1556821840-3a63f95609a7?w=600&h=800&fit=crop", 4.7, 201, "Yumshoq fleece ichlikli premium hoodie.", true, false, true), | |
| _p(9, "Maktab Formalari To'plami", "formalar", "Maktab", 450000, 550000, 18, SM, ["qora", "ko_k"], "https://images.unsplash.com/photo-1604671801908-6f0c6a092c05?w=600&h=800&fit=crop", 4.5, 345, "To'liq maktab formalari to'plami.", true, false, true), | |
| _p(10, "Ofis Biznes Kostyum", "formalar", "Ish formalari", 1250000, 1500000, 17, S, ["qora", "kulrang", "ko_k"], "https://images.unsplash.com/photo-1594938298603-c8148c4dae35?w=600&h=800&fit=crop", 4.9, 156, "Premium biznes kostyum.", true, true, true), | |
| _p(11, "Tibbiyot Formasi", "formalar", "Ish formalari", 320000, null, 0, SX, ["oq", "ko_k", "yashil"], "https://images.unsplash.com/photo-1559839734-2b71ea197ec2?w=600&h=800&fit=crop", 4.3, 89, "Professional tibbiyot formasi.", true, false, false), | |
| _p(12, "Oshpaz Formasi Premium", "formalar", "Ish formalari", 380000, 450000, 16, S, ["oq", "qora"], "https://images.unsplash.com/photo-1577219491135-ce391730fb2c?w=600&h=800&fit=crop", 4.6, 67, "Professional oshpaz formasi.", true, false, false), | |
| _p(13, "Sport Forma - Futbol", "formalar", "Sport", 270000, null, 0, SM, ["ko_k", "qizil", "yashil", "oq"], "https://images.unsplash.com/photo-1574629810360-7efbbe195018?w=600&h=800&fit=crop", 4.4, 234, "Professional futbol formasi.", true, true, false), | |
| _p(14, "Harbiy Uniforma", "formalar", "Ish formalari", 580000, null, 0, SX, ["yashil", "kulrang"], "https://images.unsplash.com/photo-1579912861630-f7c8ad0c7804?w=600&h=800&fit=crop", 4.7, 45, "Yuqori sifatli uniforma.", true, false, false), | |
| _p(15, "Qizlar Maktab Formalari", "formalar", "Maktab", 420000, 490000, 14, ["XS", "S", "M", "L"], ["qora", "ko_k"], "https://images.unsplash.com/photo-1594938298603-c8148c4dae35?w=600&h=800&fit=crop", 4.5, 278, "Qizlar maktab formalari.", true, false, true), | |
| _p(16, "Mexanik Ish Kiyimi", "formalar", "Ish formalari", 340000, null, 0, ML, ["ko_k", "kulrang"], "https://images.unsplash.com/photo-1504307651254-35680f356dfd?w=600&h=800&fit=crop", 4.2, 56, "Mexaniklar uchun maxsus ish kiyimi.", true, false, false), | |
| _p(17, "Klassik Biznes Shim", "shimlar", "Klassik", 320000, 380000, 16, S, ["qora", "kulrang", "ko_k"], "https://images.unsplash.com/photo-1624378439575-d8705ad7ae80?w=600&h=800&fit=crop", 4.6, 189, "Premium klassik shim.", true, false, true), | |
| _p(18, "Slim Jinsi Shim", "shimlar", "Jinsi", 275000, null, 0, S, ["ko_k", "qora", "kulrang"], "https://images.unsplash.com/photo-1542272604-787c3835535d?w=600&h=800&fit=crop", 4.7, 412, "Zamonaviy slim fit jinsi shim.", true, true, true), | |
| _p(19, "Sport Shim Jogger", "shimlar", "Sport", 185000, 220000, 16, SX, ["qora", "kulrang", "ko_k"], "https://images.unsplash.com/photo-1552902865-b72c031ac5ea?w=600&h=800&fit=crop", 4.5, 298, "Sport jogger shim.", true, false, false), | |
| _p(20, "Chino Shim Classic", "shimlar", "Klassik", 245000, null, 0, S, ["jigarrang", "kulrang", "yashil", "ko_k"], "https://images.unsplash.com/photo-1473966968600-fa801b869a1a?w=600&h=800&fit=crop", 4.4, 145, "Chino shim.", true, false, false), | |
| _p(21, "Straight Fit Jinsi", "shimlar", "Jinsi", 295000, 350000, 16, ML, ["ko_k", "qora"], "https://images.unsplash.com/photo-1604176354204-9268737828e4?w=600&h=800&fit=crop", 4.5, 187, "Klassik straight fit jinsi.", true, false, false), | |
| _p(22, "Cargo Shim Tactical", "shimlar", "Sport", 310000, null, 0, S, ["yashil", "qora", "kulrang"], "https://images.unsplash.com/photo-1517438476312-10d79c077509?w=600&h=800&fit=crop", 4.3, 98, "Tactical cargo shim.", true, true, false), | |
| _p(23, "Linen Yoz Shim", "shimlar", "Klassik", 230000, 280000, 18, S, ["oq", "kulrang", "havorang"], "https://images.unsplash.com/photo-1506629082955-511b1aa562c8?w=600&h=800&fit=crop", 4.6, 76, "Yozgi linen shim.", true, false, true), | |
| _p(24, "Qisqa Sport Shorts", "shimlar", "Sport", 125000, null, 0, S, ["qora", "ko_k", "kulrang"], "https://images.unsplash.com/photo-1591195853828-11db59a44f6b?w=600&h=800&fit=crop", 4.3, 234, "Qisqa sport shorts.", true, false, false), | |
| _p(25, "Ipak Klassik Galistuk", "galistuklar", "Klassik", 185000, 220000, 16, OS, ["qora", "ko_k", "qizil"], "https://images.unsplash.com/photo-1589756823695-278bc923a423?w=600&h=800&fit=crop", 4.8, 167, "100% ipak klassik galistuk.", true, false, true), | |
| _p(26, "Slim Zamonaviy Galistuk", "galistuklar", "Slim", 145000, null, 0, OS, ["qora", "kulrang", "ko_k", "qizil"], "https://images.unsplash.com/photo-1598879400638-bb93c904ef41?w=600&h=800&fit=crop", 4.5, 234, "Zamonaviy slim galistuk.", true, true, true), | |
| _p(27, "Bowtie Premium", "galistuklar", "Bowtie", 125000, 160000, 22, OS, ["qora", "qizil", "ko_k", "yashil"], "https://images.unsplash.com/photo-1580657018950-c7f7d6a6d990?w=600&h=800&fit=crop", 4.7, 89, "Premium bowtie.", true, false, false), | |
| _p(28, "Naqshli Galistuk", "galistuklar", "Klassik", 165000, null, 0, OS, ["ko_k", "qizil"], "https://images.unsplash.com/photo-1590548784585-643d2b9f2925?w=600&h=800&fit=crop", 4.4, 112, "Naqshli galistuk.", true, false, false), | |
| _p(29, "Kashemir Galistuk", "galistuklar", "Klassik", 250000, 300000, 17, OS, ["jigarrang", "kulrang", "ko_k"], "https://images.unsplash.com/photo-1598879400638-bb93c904ef41?w=600&h=800&fit=crop", 4.9, 56, "Premium kashemir galistuk.", true, true, true), | |
| _p(30, "Mikrofiber Galistuk", "galistuklar", "Slim", 95000, null, 0, OS, ["qora", "ko_k", "kulrang"], "https://images.unsplash.com/photo-1589756823695-278bc923a423?w=600&h=800&fit=crop", 4.2, 78, "Mikrofiber galistuk.", true, false, false), | |
| _p(31, "To'y Galistuk To'plami", "galistuklar", "Klassik", 320000, 400000, 20, OS, ["oq", "qizil", "ko_k"], "https://images.unsplash.com/photo-1580657018950-c7f7d6a6d990?w=600&h=800&fit=crop", 4.8, 134, "To'y uchun galistuk to'plami.", true, false, true), | |
| _p(32, "Kids Bowtie", "galistuklar", "Bowtie", 65000, 85000, 24, OS, ["ko_k", "qizil", "qora"], "https://images.unsplash.com/photo-1580657018950-c7f7d6a6d990?w=600&h=800&fit=crop", 4.6, 45, "Bolalar uchun bowtie.", true, false, false), | |
| _p(33, "Charm Kamar Premium", "aksessuarlar", "Kamarlar", 195000, 240000, 19, S, ["qora", "jigarrang"], "https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=600&h=800&fit=crop", 4.7, 201, "Tabiiy charm kamar.", true, false, true), | |
| _p(34, "Biznes Portfel", "aksessuarlar", "Sumkalar", 520000, null, 0, OS, ["qora", "jigarrang"], "https://images.unsplash.com/photo-1548036328-c9fa89d128fa?w=600&h=800&fit=crop", 4.8, 134, "Premium biznes portfel.", true, true, true), | |
| _p(35, "Klassik Shlyapa", "aksessuarlar", "Shlyapalar", 145000, 180000, 19, ["S", "M", "L"], ["qora", "kulrang", "jigarrang"], "https://images.unsplash.com/photo-1514327605112-b887c0e61c0a?w=600&h=800&fit=crop", 4.4, 67, "Klassik fedora shlyapa.", true, false, false), | |
| _p(36, "Ipak Cho'ntak Ro'mol", "aksessuarlar", "Aksessuarlar", 85000, null, 0, OS, ["oq", "ko_k", "qizil", "pushti"], "https://images.unsplash.com/photo-1598879400638-bb93c904ef41?w=600&h=800&fit=crop", 4.5, 89, "100% ipak cho'ntak ro'mol.", true, false, false), | |
| _p(37, "Manjet Tugmalari Gold", "aksessuarlar", "Aksessuarlar", 175000, 210000, 17, OS, ["sariq"], "https://images.unsplash.com/photo-1590548784585-643d2b9f2925?w=600&h=800&fit=crop", 4.6, 56, "Oltin rangli manjet tugmalari.", true, false, false), | |
| _p(38, "Qo'lqop Charm", "aksessuarlar", "Aksessuarlar", 230000, null, 0, ["S", "M", "L"], ["qora", "jigarrang"], "https://images.unsplash.com/photo-1531163051823-59adbb4b5e8e?w=600&h=800&fit=crop", 4.8, 45, "Premium charm qo'lqop.", true, true, false), | |
| _p(39, "Pul Qisqich Carbon", "aksessuarlar", "Aksessuarlar", 155000, 190000, 18, OS, ["qora"], "https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=600&h=800&fit=crop", 4.5, 123, "Carbon fiber pul qisqich.", true, false, true), | |
| _p(40, "Sport Sumka Duffle", "aksessuarlar", "Sumkalar", 345000, null, 0, OS, ["qora", "kulrang", "ko_k"], "https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=600&h=800&fit=crop", 4.4, 167, "Keng sport duffle sumka.", true, false, false), | |
| ]; | |
| async function seed() { | |
| try { | |
| await mongoose.connect(process.env.MONGODB_URI); | |
| console.log('MongoDB ga ulandi...'); | |
| await Product.deleteMany({}); | |
| console.log('Eski mahsulotlar o\'chirildi.'); | |
| await Product.insertMany(PRODUCTS); | |
| console.log(`✅ ${PRODUCTS.length} ta mahsulot qo'shildi!`); | |
| await mongoose.disconnect(); | |
| console.log('Tayyor!'); | |
| } catch (err) { | |
| console.error('❌ Xatolik:', err.message); | |
| process.exit(1); | |
| } | |
| } | |
| seed(); | |