UNPKG

1.57 kBTypeScriptView Raw
1import { EJSON } from 'bson';
2import { SeederCollection, LogFn } from '../common';
3/**
4 * Populates collections from disk.
5 */
6export declare class CollectionPopulator {
7 /**
8 * Supported file extensions
9 */
10 extensions: string[];
11 ejsonParseOptions: EJSON.Options;
12 /**
13 * Logger instance
14 */
15 log: LogFn;
16 /**
17 * Constructs new `CollectionPopulator` object.
18 *
19 * @param extensions Array of file extensions
20 */
21 constructor(extensions: string[], ejsonParseOptions: EJSON.Options, log?: LogFn);
22 /**
23 * Reads collections from path.
24 *
25 * @param path
26 */
27 readFromPath(path: string): SeederCollection[];
28 /**
29 * Read all collections from base path
30 *
31 * @param directories Array of directories names
32 * @param inputDirectory Base directory
33 */
34 private readCollections;
35 private sortCollections;
36 /**
37 * Reads collection along with documents content from a given path.
38 *
39 * @param path Collection Path
40 * @param directoryName Directory name
41 */
42 private readCollection;
43 /**
44 * Populates MongoDB documents content by reading files.
45 *
46 * @param collectionPath Path for a single collection
47 */
48 private populateDocumentsContent;
49 /**
50 * Reads collection name from directory name.
51 *
52 * @param directoryName Directory name
53 */
54 private getCollectionMetadata;
55 /**
56 * Checks if a string is number.
57 *
58 * @param str String which can contain number
59 */
60 private isNumber;
61}