-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from SOURAV-ROY/ROY
- Loading branch information
Showing
3 changed files
with
44 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
const {faker} = require("@faker-js/faker"); | ||
const { faker } = require("@faker-js/faker"); | ||
// const CountryIndexingModel = require('../models/CountryIndexingModel'); | ||
const UserModel = require("../models/UserModel"); | ||
const mongoose = require("mongoose"); | ||
require("colors"); | ||
|
||
async function seedData() { | ||
// Connection URL | ||
const uri = "String"; | ||
const seedCount = 5000; | ||
mongoose | ||
.connect(uri, { | ||
useNewUrlParser: true, | ||
useCreateIndex: true, | ||
useFindAndModify: false, | ||
useUnifiedTopology: true, | ||
}) | ||
.then(() => { | ||
console.log("Connected To MongoDB".cyan.bold); | ||
}) | ||
.catch((err) => { | ||
console.log("ERROR".red.bold, err); | ||
}); | ||
// Connection URL | ||
const uri = "String"; | ||
const seedCount = 5000; | ||
mongoose | ||
.connect(uri, { | ||
useNewUrlParser: true, | ||
useCreateIndex: true, | ||
useFindAndModify: false, | ||
useUnifiedTopology: true, | ||
}) | ||
.then(() => { | ||
console.log("Connected To MongoDB".cyan.bold); | ||
}) | ||
.catch((err) => { | ||
console.log("ERROR".red.bold, err); | ||
}); | ||
|
||
let timeSeriesData = []; | ||
// create 5000 fake data | ||
for (let i = 0; i < seedCount; i++) { | ||
const name = faker.person.firstName(); | ||
const email = faker.internet.email(); | ||
timeSeriesData.push({name, email}); | ||
} | ||
let timeSeriesData = []; | ||
// create 5000 fake data | ||
for (let i = 0; i < seedCount; i++) { | ||
const name = faker.person.firstName(); | ||
const email = faker.internet.email(); | ||
timeSeriesData.push({ name, email }); | ||
} | ||
|
||
console.log(timeSeriesData); | ||
const seedDB = async () => { | ||
await UserModel.insertMany(timeSeriesData); | ||
}; | ||
console.log(timeSeriesData); | ||
const seedDB = async () => { | ||
await UserModel.insertMany(timeSeriesData); | ||
}; | ||
|
||
seedDB().then(() => { | ||
mongoose.connection.close(); | ||
}); | ||
seedDB().then(() => { | ||
mongoose.connection.close(); | ||
}); | ||
} | ||
|
||
seedData().then(() => { | ||
console.log("SUCCESSFULLY INSERT".green.bold); | ||
console.log("SUCCESSFULLY INSERT".green.bold); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2f52c11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
bootcamps – ./
bootcamps.vercel.app
bootcamps-sourav-roy.vercel.app
bootcamps-git-sourav-sourav-roy.vercel.app