mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(seed): show connection message if connected (#53421)
This commit is contained in:
committed by
GitHub
parent
37919574b0
commit
0738694caa
@@ -24,11 +24,6 @@ const examFilenames = [
|
||||
|
||||
const client = new MongoClient(MONGOHQ_URL, { useUnifiedTopology: true });
|
||||
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const exams = db.collection('Exam');
|
||||
|
||||
function handleError(err, client) {
|
||||
if (err) {
|
||||
console.error('Oh noes!! Error seeding exams.');
|
||||
@@ -45,6 +40,11 @@ function handleError(err, client) {
|
||||
}
|
||||
|
||||
const seed = async () => {
|
||||
await client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const exams = db.collection('Exam');
|
||||
for (const filename of examFilenames) {
|
||||
try {
|
||||
const examPath = join(__dirname, 'exams', filename);
|
||||
|
||||
@@ -243,7 +243,7 @@ const dropUsers = async function () {
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
await client.connect();
|
||||
await client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
await dropUserTokens();
|
||||
|
||||
@@ -44,12 +44,12 @@ const certifiedUserAccount = {
|
||||
|
||||
const client = new MongoClient(MONGOHQ_URL, { useNewUrlParser: true });
|
||||
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const msUsername = db.collection('MsUsername');
|
||||
|
||||
const run = async () => {
|
||||
await client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const msUsername = db.collection('MsUsername');
|
||||
if (args.includes('--delete-only')) {
|
||||
await msUsername.deleteOne({
|
||||
_id: { $eq: msAccountId }
|
||||
|
||||
@@ -74,12 +74,13 @@ const certifiedUserSurvey = {
|
||||
|
||||
const client = new MongoClient(MONGOHQ_URL, { useNewUrlParser: true });
|
||||
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const survey = db.collection('Survey');
|
||||
|
||||
const run = async () => {
|
||||
await client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const survey = db.collection('Survey');
|
||||
|
||||
await survey.deleteMany({
|
||||
_id: {
|
||||
$in: surveyIds
|
||||
|
||||
Reference in New Issue
Block a user