New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the dbseed.js script #263
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/drewclem/protege/or3KD8o1d5eosyyt71SBGk4KhiAD |
|
||
// Seeding data is only for non-production environments. | ||
if (process.env.NODE_ENV === 'production') { | ||
throw new Error( |
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.
Throw an error if we are in the production environment.
try { | ||
;[...Array(10).keys()].map(() => |
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.
We don't need to map the array as we're not mapping to anything. A loop is good for the job.
;[...Array(10).keys()].map(() => | ||
db.collection('jobs').add({ | ||
for (let i = 0; i < seedSize; i++) { | ||
const job = { |
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.
I found it difficult to grok the job when it was directly in the add method. Happy to put it back if you prefer that.
Looks good @nickytonline. Thanks!! |
One notable change is to Failing to do so will result in the following error.
|
Description
Incorporates all the improvements suggested for dbseed.js in #262.
Related Tickets & Documents
Closes #262
QA Instructions, Screenshots, Recordings
gh co 263
yarn
to install the new packages.yarn emulators
to ensure the emulated Firestore is running.node dbseed.js
from the root of the project. The database should seed with 10 jobs.yarn emulators
command via CTRL + Cyarn emulators
to ensure the emulated Firestore is running.node dbseed.js --seedSize=15
from the root of the project. The database should seed with 15 jobs.[optional] What gif best describes this PR or how it makes you feel?