I'm trying to learn how to use MongoDB with PHP. I Have built a web application that loads data from database etc. The issue I am having is that when I import my data from a .CSV using MongoDB Compass, by default everything is imported as a string.
I have also tried to do it using cmd with the following but had no luck;
mongoimport --db hddatabase --collection crimes --type csv --columnsHaveTypes --fields "CrimeID.string(),CrimeMonth.date(2006-01),CrimeReportedIn.string(),CrimeFallsWithin.string(),CrimeLongitude.double(),CrimeLatitude.double(),CrimeLocation.string(),CrimeLSOACode.string(),CrimeLSOAName.string(), CrimeType.string(), CrimeLastOutcomeCategory.string(), CrimeContext.string()" --file C:\Users\01\Desktop\desk\WestCrime.csv
I can see how to use the MongoDB Compass GUI to change the value of individual documents manually.. I cannot for the life of my work out how to do this for all documents in a collection. Any help for the issue would be greatly appreciated.
I tried the below based on recommendation and am getting "Could not parse type from header CrimeReporttedIn.string(); 0 documents imported
mongoimport --db hddatabase --collection crimes --type csv --fields CrimeReportedIn.string\(\),CrimeFallsWithin.string\(\),CrimeLongitude.double\(\),CrimeLatitude.double\(\),CrimeLocation.string\(\),CrimeLSOACode.string\(\),CrimeLSOAName.string\(\),CrimeType.string\(\),CrimeLastOutcomeCategory.string\(\),CrimeContext.string\(\) --columnsHaveTypes --file C:\Users\01\Desktop\desk\WestCrime.csv