-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathseedMatches.js
More file actions
115 lines (100 loc) · 4.34 KB
/
Copy pathseedMatches.js
File metadata and controls
115 lines (100 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const mongoose = require("mongoose");
if (process.env.NODE_ENV !== "production") {
require("dotenv").config();
}
const Startup = require("./models/Startup");
const Investor = require("./models/Investor");
const Match = require("./models/Match");
const User = require("./models/User"); // Need User for references
const dbUrl = process.env.DB_URL || "mongodb://127.0.0.1:27017/nexus";
// Connect to MongoDB
mongoose.connect(dbUrl)
.then(() => console.log("Connected to MongoDB for Seeding"))
.catch(err => console.error("Could not connect to MongoDB", err));
const seedData = async () => {
try {
// Clear existing data (optional, but good for testing)
await Startup.deleteMany({});
await Investor.deleteMany({});
await Match.deleteMany({});
await User.deleteMany({});
console.log("Cleared existing data");
// Create Dummy Users using register for password hashing
const user1 = new User({ username: "startup1", email: "s1@test.com", role: "startup", hasFilledProfile: true });
const registeredUser1 = await User.register(user1, "password123");
const user2 = new User({ username: "investor1", email: "i1@test.com", role: "investor", hasFilledProfile: true });
const registeredUser2 = await User.register(user2, "password123");
const user3 = new User({ username: "startup2", email: "s2@test.com", role: "startup", hasFilledProfile: true });
const registeredUser3 = await User.register(user3, "password123");
const user4 = new User({ username: "investor2", email: "i2@test.com", role: "investor", hasFilledProfile: true });
const registeredUser4 = await User.register(user4, "password123");
// Create Dummy Startups
const startups = [
{
userId: registeredUser1._id,
startupName: "TechNova",
industry: "Technology",
stage: "Seed",
fundingRequired: 500000,
equityOffered: 10,
location: "Bangalore",
revenueStatus: "Pre-Revenue",
teamSize: 5,
pitchDescription: "AI-driven matchmaking for jobs.",
tags: ["AI", "Recruitment", "SaaS"]
},
{
userId: user3._id,
startupName: "GreenEarth",
industry: "CleanTech",
stage: "Pre-Seed",
fundingRequired: 100000,
equityOffered: 15,
location: "Delhi",
revenueStatus: "Pre-Revenue",
teamSize: 2,
pitchDescription: "Sustainable packaging solutions.",
tags: ["Environment", "Sustainability", "Plastic-Free"]
}
];
const createdStartups = await Startup.insertMany(startups);
console.log(`Created ${createdStartups.length} startups`);
// Create Dummy Investors
const investors = [
{
userId: user2._id,
investorName: "VentureCapital One",
firmName: "VC One",
email: "contact@vcone.com",
preferredIndustries: ["Technology", "SaaS"],
preferredStage: "Seed",
investmentType: "Equity",
minInvestment: 200000,
maxInvestment: 1000000,
locationPreference: "Bangalore",
bio: "Looking for high-growth tech startups."
},
{
userId: registeredUser4._id,
investorName: "Angel Investor Bob",
firmName: "Bob Angels",
email: "bob@angels.com",
preferredIndustries: ["CleanTech", "Healthcare"],
preferredStage: "Pre-Seed",
investmentType: "Convertible Note",
minInvestment: 50000,
maxInvestment: 200000,
locationPreference: "Any",
bio: "Investing in sustainable future."
}
];
const createdInvestors = await Investor.insertMany(investors);
console.log(`Created ${createdInvestors.length} investors`);
console.log("Seeding Completed!");
mongoose.connection.close();
} catch (error) {
console.error("Error seeding data:", error);
mongoose.connection.close();
}
};
seedData();