mongoose-seed-csv is a wrapper for mongoose-seed that will parse data from csv files
const seeder = require('mongoose-seed-csv');
seeder.populateFromCSV(
[
'./test/location.csv',
{path: './test/map.csv', model: 'Map', parseOptions: {columns: true}}
],
{columns: true},
function(){
seeder.disconnect();
});
- csvEntryArray: [string(filepath) || CSV_Entry]
- you can you both filepath and CSV_Entry Object and even mixed
- csvParseOptions
- callback
- same callback as in mongoose-seed's populateModels
/**
* @typedef {object} CSV_Entry
* @property {string} path - csv file path
* @property {string} [model] - model name
* @property {string} [parseOptions] - individual parse option (it will override csvParseOption)
*/