fix(seed): Use correct collection name and document id
This commit is contained in:
committed by
mrugesh mohapatra
parent
162e25143e
commit
e5a4ffa93b
@ -35,7 +35,7 @@ MongoClient.connect(
|
|||||||
log('Connected successfully to mongo');
|
log('Connected successfully to mongo');
|
||||||
|
|
||||||
const db = client.db('freecodecamp');
|
const db = client.db('freecodecamp');
|
||||||
const challenges = db.collection('challenges');
|
const challenges = db.collection('challenge');
|
||||||
|
|
||||||
challenges.deleteMany({}, err => {
|
challenges.deleteMany({}, err => {
|
||||||
handleError(err, client);
|
handleError(err, client);
|
||||||
@ -49,7 +49,12 @@ MongoClient.connect(
|
|||||||
key => superBlock[key].challenges
|
key => superBlock[key].challenges
|
||||||
);
|
);
|
||||||
return [...challengeArray, ...flatten(challengesForBlock)];
|
return [...challengeArray, ...flatten(challengesForBlock)];
|
||||||
}, []);
|
}, [])
|
||||||
|
.map(challenge => {
|
||||||
|
challenge._id = challenge.id.slice(0);
|
||||||
|
delete challenge.id;
|
||||||
|
return challenge;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
challenges.insertMany(allChallenges, { ordered: false });
|
challenges.insertMany(allChallenges, { ordered: false });
|
||||||
|
Reference in New Issue
Block a user