# Function

Static Public Summary
public | aliasToCommand(alias: string): string Get the command name of a given alias |
public | commandToFunction(command: string): Function Get the function of a given command |
public | exit(error: Error) Exit mongoose-data-seed. |
public | async generateSeeder(name: string): Promise Generate a new seeder. |
public | getCommandAndArgvFromCli(): Object Get the command and the arguments from the cli |
public | getFolderNameFromPath(path: string): string Get folder name from given path. |
public | getObjectWithSelectedKeys(obj: Object, keys: string[]): Object Get object with selected keys from a given object. |
public | getOptions(argv: string[]): Object Get generate options from argv |
public | getOptions(argv: string[]): Object Get init options from argv |
public | getOptions(argv: string[]): Object Get run options from argv or prompts |
public | help() Prints the generate command user-guide |
public | async help() Prints the help |
public | help() Prints the install command user-guide |
public | help() Prints the run command user-guide |
public | async index(argv: stringp[]): Promise mongoose-data-seed generate command |
public | async index(argv: stringp[]): Promise mongoose-data-seed init command |
public | async index(argv: stringp[]): Promise mongoose-data-seed run command |
public | isAlias(command: string): Boolean Whether a given command is an alias |
public | normalizeSeederFileName(name: string): string Normalize seeder filename. |
public | normalizeSeederName(name: string): string Normalize seeder name. |
public | async promptMissingOptions(options: Object): Promise Prompt missing options for init command |
public | async run(options: Object): Promise Run seeders |
public | runCommand(command: string, argv: string): * Run command |
public | async runinstaller(options: Object): Promise Run the installer |
public | validateOptions(options: Object) Validate generate command options |
public | validateSeederTemplatePath(name: string): boolean Validate seeder template path. |
public | validateSeedersFolderName(name: string): boolean Validate seeders folder name. |
public | validateUserConfig() Validate user config. |

## Static Public

### public aliasToCommand(alias: string): string source

    import {aliasToCommand} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Get the command name of a given alias

#### Params:

Name | Type | Attribute | Description
alias | string |  |

#### Return:

string

### public commandToFunction(command: string): Function source

    import {commandToFunction} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Get the function of a given command

#### Params:

Name | Type | Attribute | Description
command | string |  | command name

#### Return:

Function | command function

### public exit(error: Error) source

    import {exit} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Exit mongoose-data-seed.

#### Params:

Name | Type | Attribute | Description
error | Error | optional | Exit with error when supplied.

### public async generateSeeder(name: string): Promise source

    import generateSeeder from 'mongoose-data-seed/src/lib/commands/generate/generate-seeder.js'

Generate a new seeder.

#### Params:

Name | Type | Attribute | Description
name | string |  | seeder name

#### Return:

Promise

### public getCommandAndArgvFromCli(): Object source

    import {getCommandAndArgvFromCli} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Get the command and the arguments from the cli

#### Return:

Object

#### Return Properties:

Name | Type | Attribute | Description
command | string |  | command name
argv | string[] |  | command arguments

### public getFolderNameFromPath(path: string): string source

    import {getFolderNameFromPath} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Get folder name from given path.

#### Params:

Name | Type | Attribute | Description
path | string |  | path

#### Return:

string | folder name

### public getObjectWithSelectedKeys(obj: Object, keys: string[]): Object source

    import {getObjectWithSelectedKeys} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Get object with selected keys from a given object.

#### Params:

Name | Type | Attribute | Description
obj | Object |  | Object
keys | string[] |  | Keys to get from the given object.

#### Return:

Object | new object with the selected keys.

### public getOptions(argv: string[]): Object source

    import {getOptions} from 'mongoose-data-seed/src/lib/commands/generate/options.js'

Get generate options from argv

#### Params:

Name | Type | Attribute | Description
argv | string[] |  | cli argv

#### Return:

Object | run options

#### Return Properties:

Name | Type | Attribute | Description
seederName | string |  |
helpWanted | boolean |  |

### public getOptions(argv: string[]): Object source

    import {getOptions} from 'mongoose-data-seed/src/lib/commands/init/options.js'

Get init options from argv

#### Params:

Name | Type | Attribute | Description
argv | string[] |  | cli argv

#### Return:

Object | init options

#### Return Properties:

Name | Type | Attribute | Description
seedersFolder | string |  |
customSeederTemplate | string |  |
helpWanted | boolean |  |

### public getOptions(argv: string[]): Object source

    import {getOptions} from 'mongoose-data-seed/src/lib/commands/run/options.js'

Get run options from argv or prompts

#### Params:

Name | Type | Attribute | Description
argv | string[] |  | cli argv

#### Return:

Object | run options

#### Return Properties:

Name | Type | Attribute | Description
selectedSeeders | string[] |  |
dropDatabase | boolean |  |
helpWanted | boolean |  |

### public help() source

    import help from 'mongoose-data-seed/src/lib/commands/generate/help.js'

Prints the generate command user-guide

### public async help() source

    import help from 'mongoose-data-seed/src/lib/commands/help/index.js'

Prints the help

### public help() source

    import help from 'mongoose-data-seed/src/lib/commands/init/help.js'

Prints the install command user-guide

### public help() source

    import help from 'mongoose-data-seed/src/lib/commands/run/help.js'

Prints the run command user-guide

### public async index(argv: stringp[]): Promise source

    import index from 'mongoose-data-seed/src/lib/commands/generate/index.js'

mongoose-data-seed generate command

#### Params:

Name | Type | Attribute | Description
argv | stringp[] |  | cli arguments

#### Return:

Promise

### public async index(argv: stringp[]): Promise source

    import index from 'mongoose-data-seed/src/lib/commands/init/index.js'

mongoose-data-seed init command

#### Params:

Name | Type | Attribute | Description
argv | stringp[] |  | cli arguments

#### Return:

Promise

### public async index(argv: stringp[]): Promise source

    import index from 'mongoose-data-seed/src/lib/commands/run/index.js'

mongoose-data-seed run command

#### Params:

Name | Type | Attribute | Description
argv | stringp[] |  | cli arguments

#### Return:

Promise

### public isAlias(command: string): Boolean source

    import {isAlias} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Whether a given command is an alias

#### Params:

Name | Type | Attribute | Description
command | string |  |

#### Return:

Boolean

### public normalizeSeederFileName(name: string): string source

    import {normalizeSeederFileName} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Normalize seeder filename.

#### Params:

Name | Type | Attribute | Description
name | string |  | seeder name

#### Return:

string | normalized seeder filename

### public normalizeSeederName(name: string): string source

    import {normalizeSeederName} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Normalize seeder name.

#### Params:

Name | Type | Attribute | Description
name | string |  | seeder name

#### Return:

string | normalized seeder name

### public async promptMissingOptions(options: Object): Promise source

    import {promptMissingOptions} from 'mongoose-data-seed/src/lib/commands/init/options.js'

Prompt missing options for init command

#### Params:

Name | Type | Attribute | Description
options | Object | optional default: {} | Init command options
options.seedersFolder | [type] |  | seeders folder
options.customSeederTemplate | [type] |  | custom seeder template

#### Return:

Promise | Options without missing

### public async run(options: Object): Promise source

    import run from 'mongoose-data-seed/src/lib/commands/run/run.js'

Run seeders

#### Params:

Name | Type | Attribute | Description
options | Object | optional default: {} | Options
options.selectedSeeders | string[] | optional default: [] | Selected seeders to run. When empty, run all seeders.
options.dropDatabase | boolean | optional default: false | Drop database before running?

#### Return:

Promise

### public runCommand(command: string, argv: string): * source

    import {runCommand} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Run command

#### Params:

Name | Type | Attribute | Description
command | string |  | command name
argv | string |  | command arguments

#### Return:

*

### public async runinstaller(options: Object): Promise source

    import runinstaller from 'mongoose-data-seed/src/lib/commands/init/run-installer.js'

Run the installer

#### Params:

Name | Type | Attribute | Description
options | Object | optional default: {} | installer options
options.seedersFolder | string |  |
options.seedersTemplate | string |  |

#### Return:

Promise

### public validateOptions(options: Object) source

    import {validateOptions} from 'mongoose-data-seed/src/lib/commands/generate/options.js'

Validate generate command options

#### Params:

Name | Type | Attribute | Description
options | Object | optional default: {} | Options
options.seederName | string |  | seeder name to generate
options.helpWanted | boolean |  | help wanted?

#### Throw:

Error | throw error when options are not valid.

### public validateSeederTemplatePath(name: string): boolean source

    import {validateSeederTemplatePath} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Validate seeder template path.

#### Params:

Name | Type | Attribute | Description
name | string |  | path

#### Return:

boolean

### public validateSeedersFolderName(name: string): boolean source

    import {validateSeedersFolderName} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Validate seeders folder name.

#### Params:

Name | Type | Attribute | Description
name | string |  | folder name

#### Return:

boolean

### public validateUserConfig() source

    import {validateUserConfig} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Validate user config.

#### Throw:

Error | throw error when user config is not valid.