node.js - Automatically populating a database when running Mean.js application -
for mean.js project working on, have csv file of data need check against in 1 of server controllers. instead of opening csv file in controller every time check want move of data mongo database , quick query check. normally, database manipulation simple python script, project working on mean stack supplied mean.js, team of few engineers, on several different environments.
so, want figure out way automatically create , populate database within mean.js app so:
- i have access environment variables (especially database names)
- this database can created on other engineers' machines , in other environments
- it run first time engineer builds app after pulling changes
i using grunt application-wide task manager, runs each task every time application built means repetitively.
does have better suggestions on how this?
two suggestions:
first, use npm scripts: https://docs.npmjs.com/misc/scripts
so, instance if "create database" script python file add package.json
:
{ ... "scripts": { "createdb": "python create_database.py" } ... }
and can run when need this:
npm run-script createdb
still, manual. leads second suggestion:
you can create grunt task populates database, , after running creates hidden file indicating has been run. before running check if file present, if so, skip task.
add hidden file .gitignore
, every time project cloned , grunt fired up, database populated once.
Comments
Post a Comment