问题
I have a .CSV
export file from a SQL Server database, with a phone number field (number type) that field values started with leading zero.
Leading zero is presented in the CSV file.
When I attempt to mongoimport it to DB (in string type) I find data imported without leading zero.
The target field number is string. How can I solve this problem?
回答1:
you can specifically define the type of the field using the import option --columnsHaveTypes
Instructs mongoimport that the field list specified in --fields, --fieldFile, or --headerline specifies the types of each field.
MongoDB Manual
来源:https://stackoverflow.com/questions/59436300/mongoimport-ignore-leading-zero-in-csv