fix(seed): show connection message if connected (#53421)

This commit is contained in:
Oliver Eyton-Williams
2024-01-29 20:08:08 +01:00
committed by GitHub
parent 37919574b0
commit 0738694caa
4 changed files with 17 additions and 16 deletions
+5 -5
View File
@@ -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);
+1 -1
View File
@@ -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();
+5 -5
View File
@@ -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 }
+6 -5
View File
@@ -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