61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
// MongoDB initialization script
|
|
db = db.getSiblingDB('code_repository');
|
|
|
|
// Create collections
|
|
db.createCollection('code_templates');
|
|
db.createCollection('framework_configs');
|
|
db.createCollection('generated_projects');
|
|
db.createCollection('ai_prompts');
|
|
|
|
// Create indexes
|
|
db.code_templates.createIndex({ "framework": 1, "language": 1, "type": 1 });
|
|
db.framework_configs.createIndex({ "name": 1, "version": 1 });
|
|
db.generated_projects.createIndex({ "project_id": 1 });
|
|
db.ai_prompts.createIndex({ "category": 1, "framework": 1 });
|
|
|
|
// Insert sample templates
|
|
db.code_templates.insertMany([
|
|
{
|
|
framework: "react",
|
|
language: "typescript",
|
|
type: "component",
|
|
template_name: "basic_component",
|
|
template_content: "// React TypeScript Component Template",
|
|
created_at: new Date(),
|
|
version: "1.0"
|
|
},
|
|
{
|
|
framework: "nodejs",
|
|
language: "typescript",
|
|
type: "api_controller",
|
|
template_name: "rest_controller",
|
|
template_content: "// Node.js Express Controller Template",
|
|
created_at: new Date(),
|
|
version: "1.0"
|
|
}
|
|
]);
|
|
|
|
// Insert framework configurations
|
|
db.framework_configs.insertMany([
|
|
{
|
|
name: "react",
|
|
version: "18.2.0",
|
|
dependencies: ["@types/react", "@types/react-dom", "typescript"],
|
|
dev_dependencies: ["@vitejs/plugin-react", "vite"],
|
|
build_command: "npm run build",
|
|
dev_command: "npm run dev",
|
|
created_at: new Date()
|
|
},
|
|
{
|
|
name: "nodejs",
|
|
version: "20.0.0",
|
|
dependencies: ["express", "typescript", "@types/node"],
|
|
dev_dependencies: ["nodemon", "ts-node"],
|
|
build_command: "npm run build",
|
|
dev_command: "npm run dev",
|
|
created_at: new Date()
|
|
}
|
|
]);
|
|
|
|
print("MongoDB initialized successfully with sample data");
|