Beispiel: Importieren von Daten in MongoDB

Sei folgendes Beispiel gegeben:

In MongoDB können wir die Daten wie folgt importieren:

deparments.csv

tail -n+2 /mnt/workspace/departments.csv | mongoimport \
--drop \
--db=satisfaction \
--collection=Department \
--type=csv \
--columnsHaveTypes \
--fields='_id.int32(),name.string(),city.string(),zip_code.string()'

employees.csv

tail -n+2 /mnt/workspace/employee_processed.csv |mongoimport \
--drop \
--db=satisfaction \
--collection=Employee \
--type=csv \
--columnsHaveTypes \
--fields='_id.int32(),age.int32(),education.string(),recruitment_type.string(),job_level.int32(),rating.string(),awards.int32(),certifications.int32(),salary.double(),gender.string(),entry_date.date(2006-01-02),satisfied.int32(),department_id.int32()'

projects.csv

tail -n+2 /mnt/workspace/project_processed.csv | mongoimport \
--drop \
--db=satisfaction \
--collection=Project \
--type=csv \
--columnsHaveTypes \
--fields='_id.int32(),department_id.int32(),title.string(),proj_image.binary(base64),budget.double(),start_date.date(2006-01-02 15:04:05),end_date.date(2006-01-02 15:04:05)'