Skip to content

noizbuster/mongoose-seed-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoose-seed-csv

mongoose-seed-csv is a wrapper for mongoose-seed that will parse data from csv files

Usage

const seeder = require('mongoose-seed-csv');
seeder.populateFromCSV(
    [
        './test/location.csv',
        {path: './test/map.csv', model: 'Map', parseOptions: {columns: true}}
    ],
    {columns: true, parseDeep: true},
    function(){
        seeder.disconnect();
    });

Methods

seeder.populateFromCSV(csvEntryArray, [csvParseOptions], [callback])

  • csvEntryArray: [string(filepath) || CSV_Entry]
    • you can you both filepath and CSV_Entry Object and even mixed
  • csvParseOptions
  • callback

CSV_EntryObject

/**
 * @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)
 */

Dependencies

About

Seed data from *.csv files for Mongoose

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published