194 lines
5.4 KiB
JavaScript
194 lines
5.4 KiB
JavaScript
// MongoDB initialization script
|
|
db = db.getSiblingDB('BCardsDB');
|
|
|
|
// Create collections
|
|
db.createCollection('users');
|
|
db.createCollection('userpages');
|
|
db.createCollection('categories');
|
|
db.createCollection('subscriptions');
|
|
db.createCollection('themes');
|
|
|
|
// Create indexes for users
|
|
db.users.createIndex({ "email": 1 }, { unique: true });
|
|
db.users.createIndex({ "stripeCustomerId": 1 });
|
|
|
|
// Create indexes for userpages
|
|
db.userpages.createIndex({ "userId": 1 });
|
|
db.userpages.createIndex({ "category": 1, "slug": 1 }, { unique: true });
|
|
db.userpages.createIndex({ "category": 1 });
|
|
db.userpages.createIndex({ "isActive": 1 });
|
|
db.userpages.createIndex({ "publishedAt": -1 });
|
|
|
|
// Create indexes for categories
|
|
db.categories.createIndex({ "slug": 1 }, { unique: true });
|
|
db.categories.createIndex({ "isActive": 1 });
|
|
|
|
// Create indexes for subscriptions
|
|
db.subscriptions.createIndex({ "userId": 1 });
|
|
db.subscriptions.createIndex({ "stripeSubscriptionId": 1 });
|
|
db.subscriptions.createIndex({ "status": 1 });
|
|
|
|
// Create indexes for themes
|
|
db.themes.createIndex({ "isActive": 1 });
|
|
db.themes.createIndex({ "isPremium": 1 });
|
|
|
|
// Insert default categories
|
|
db.categories.insertMany([
|
|
{
|
|
name: "Corretor de Imóveis",
|
|
slug: "corretor",
|
|
icon: "🏠",
|
|
description: "Profissionais especializados em compra, venda e locação de imóveis",
|
|
seoKeywords: ["corretor", "imóveis", "casa", "apartamento", "venda", "locação"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Tecnologia",
|
|
slug: "tecnologia",
|
|
icon: "💻",
|
|
description: "Empresas e profissionais de tecnologia, desenvolvimento e TI",
|
|
seoKeywords: ["desenvolvimento", "software", "programação", "tecnologia", "TI"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Saúde",
|
|
slug: "saude",
|
|
icon: "🏥",
|
|
description: "Profissionais da saúde, clínicas e consultórios médicos",
|
|
seoKeywords: ["médico", "saúde", "clínica", "consulta", "tratamento"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Educação",
|
|
slug: "educacao",
|
|
icon: "📚",
|
|
description: "Professores, escolas, cursos e instituições de ensino",
|
|
seoKeywords: ["educação", "ensino", "professor", "curso", "escola"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Comércio",
|
|
slug: "comercio",
|
|
icon: "🛍️",
|
|
description: "Lojas, e-commerce e estabelecimentos comerciais",
|
|
seoKeywords: ["loja", "comércio", "venda", "produtos", "e-commerce"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Serviços",
|
|
slug: "servicos",
|
|
icon: "🔧",
|
|
description: "Prestadores de serviços gerais e especializados",
|
|
seoKeywords: ["serviços", "prestador", "profissional", "especializado"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Alimentação",
|
|
slug: "alimentacao",
|
|
icon: "🍽️",
|
|
description: "Restaurantes, delivery, food trucks e estabelecimentos alimentícios",
|
|
seoKeywords: ["restaurante", "comida", "delivery", "alimentação", "gastronomia"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Beleza",
|
|
slug: "beleza",
|
|
icon: "💄",
|
|
description: "Salões de beleza, barbearias, estética e cuidados pessoais",
|
|
seoKeywords: ["beleza", "salão", "estética", "cabeleireiro", "manicure"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Advocacia",
|
|
slug: "advocacia",
|
|
icon: "⚖️",
|
|
description: "Advogados, escritórios jurídicos e consultoria legal",
|
|
seoKeywords: ["advogado", "jurídico", "direito", "advocacia", "legal"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Arquitetura",
|
|
slug: "arquitetura",
|
|
icon: "🏗️",
|
|
description: "Arquitetos, engenheiros e profissionais da construção",
|
|
seoKeywords: ["arquiteto", "engenheiro", "construção", "projeto", "reforma"],
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
}
|
|
]);
|
|
|
|
// Insert default themes
|
|
db.themes.insertMany([
|
|
{
|
|
name: "Minimalista",
|
|
primaryColor: "#2563eb",
|
|
secondaryColor: "#1d4ed8",
|
|
backgroundColor: "#ffffff",
|
|
textColor: "#1f2937",
|
|
backgroundImage: "",
|
|
isPremium: false,
|
|
cssTemplate: "minimal",
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Dark Mode",
|
|
primaryColor: "#10b981",
|
|
secondaryColor: "#059669",
|
|
backgroundColor: "#111827",
|
|
textColor: "#f9fafb",
|
|
backgroundImage: "",
|
|
isPremium: false,
|
|
cssTemplate: "dark",
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Natureza",
|
|
primaryColor: "#16a34a",
|
|
secondaryColor: "#15803d",
|
|
backgroundColor: "#f0fdf4",
|
|
textColor: "#166534",
|
|
backgroundImage: "/images/themes/nature-bg.jpg",
|
|
isPremium: false,
|
|
cssTemplate: "nature",
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Corporativo",
|
|
primaryColor: "#1e40af",
|
|
secondaryColor: "#1e3a8a",
|
|
backgroundColor: "#f8fafc",
|
|
textColor: "#0f172a",
|
|
backgroundImage: "",
|
|
isPremium: false,
|
|
cssTemplate: "corporate",
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
},
|
|
{
|
|
name: "Vibrante",
|
|
primaryColor: "#dc2626",
|
|
secondaryColor: "#b91c1c",
|
|
backgroundColor: "#fef2f2",
|
|
textColor: "#7f1d1d",
|
|
backgroundImage: "",
|
|
isPremium: true,
|
|
cssTemplate: "vibrant",
|
|
isActive: true,
|
|
createdAt: new Date()
|
|
}
|
|
]);
|
|
|
|
print("Database initialized successfully!");
|
|
print("Collections created with indexes and default data inserted."); |