mongo-seeding
Version:
The ultimate Node.js library for populating your MongoDB database.
69 lines (68 loc) • 2.01 kB
TypeScript
import { EJSONOptions } from 'bson';
/**
* Provides functionality for manipulating files and directories.
*/
export declare class FileSystem {
static FILE_NAME_SPLIT_CHARACTER: string;
/**
* Lists file names for a given path.
*
* @param path File path
*/
listFileNames(path: string): string[];
/**
* Lists directories which are not empty or hidden.
*
* @param path File path
*/
listValidDirectories(path: string): string[];
/**
* Checks if a directory is empty.
*
* @param path File path
*/
isEmpty(path: string): boolean;
/**
* Checks if a file or directory is empty.
*
* @param fileOrDirectoryName File or directory name
*/
isHidden(fileOrDirectoryName: string): boolean;
/**
* Checks if a path is a directory.
*
* @param path File path
*/
isDirectory(path: string): boolean;
/**
* Filters files which are supported for database seeding.
*
* @param fileNames Array of file names
* @param supportedExtensions Supported file extensions array
*/
filterSupportedDocumentFileNames(fileNames: string[], supportedExtensions: string[]): string[];
/**
* Checks if a file should be ignored based on extension.
*
* @param fileNameSplitByDot Array, which comes from file name split by dot
*/
shouldIgnoreFile(fileNameSplitByDot: string[]): boolean;
/**
* Reads content for multiple files.
*
* @param paths Array of paths
* @param ejsonParseOptions EJSON parse options
*/
readFilesContent(paths: string[], ejsonParseOptions: EJSONOptions): object[];
/**
* Reads a file from path. If it is a JSON, uses EJSON parser.
*
* @param path File path
* @param ejsonParseOptions EJSON parse options
*/
readFile(path: string, ejsonParseOptions: EJSONOptions): unknown;
}
/**
* Default `FileSystem` instance
*/
export declare const fileSystem: FileSystem;