mongo-seeding
Version:
The ultimate Node.js library for populating your MongoDB database.
64 lines (63 loc) • 1.66 kB
TypeScript
import { EJSONOptions } from 'bson';
import { SeederCollection, LogFn } from '../common';
/**
* Populates collections from disk.
*/
export declare class CollectionPopulator {
/**
* Supported file extensions
*/
extensions: string[];
ejsonParseOptions: EJSONOptions;
/**
* Logger instance
*/
log: LogFn;
/**
* Constructs new `CollectionPopulator` object.
*
* @param extensions Array of file extensions
* @param ejsonParseOptions EJSON parse options
* @param log Logger instance
*/
constructor(extensions: string[], ejsonParseOptions: EJSONOptions, log?: LogFn);
/**
* Reads collections from path.
*
* @param path
*/
readFromPath(path: string): SeederCollection[];
/**
* Read all collections from base path
*
* @param directories Array of directories names
* @param inputDirectory Base directory
*/
private readCollections;
private sortCollections;
/**
* Reads collection along with documents content from a given path.
*
* @param path Collection Path
* @param directoryName Directory name
*/
private readCollection;
/**
* Populates MongoDB documents content by reading files.
*
* @param collectionPath Path for a single collection
*/
private populateDocumentsContent;
/**
* Reads collection name from directory name.
*
* @param directoryName Directory name
*/
private getCollectionMetadata;
/**
* Checks if a string is number.
*
* @param str String which can contain number
*/
private isNumber;
}