1 | import { DeepPartial, SeederCollection, LogFn } from './common';
|
2 | import { SeederCollectionReadingOptions, SeederConfig } from './config';
|
3 | export * from './config';
|
4 | export * from './helpers';
|
5 |
|
6 |
|
7 |
|
8 | export declare class Seeder {
|
9 | |
10 |
|
11 |
|
12 | static Transformers: {
|
13 | replaceDocumentIdWithUnderscoreId: (collection: SeederCollection) => SeederCollection;
|
14 | setCreatedAtTimestamp: (collection: SeederCollection) => SeederCollection;
|
15 | setUpdatedAtTimestamp: (collection: SeederCollection) => SeederCollection;
|
16 | };
|
17 | |
18 |
|
19 |
|
20 | log: LogFn;
|
21 | |
22 |
|
23 |
|
24 | config: SeederConfig;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 | constructor(config?: DeepPartial<SeederConfig>);
|
31 | /**
|
32 | * Populates collections and their documents from given path.
|
33 | * The path has to contain file structure described on https://github.com/pkosiec/mongo-seeding/blob/main/docs/import-data-definition.md.
|
34 | *
|
35 | * @param path File path
|
36 | * @param partialConfig Optional partial collection reading configuration object. It is merged with default configuration object. To use all default settings, simply omit this parameter.
|
37 | */
|
38 | readCollectionsFromPath: (path: string, partialConfig?: DeepPartial<SeederCollectionReadingOptions> | undefined) => SeederCollection[];
|
39 | /**
|
40 | * Connects to a database and imports all collections.
|
41 | *
|
42 | * @param collections Array of collection definitions
|
43 | * @param partialConfig Optional partial configuration object. Ita allows to change the database seeding configuration for single data import. It is merged with default configuration object. To use the configuration provided in `Seeder` constructor, simply omit this parameter.
|
44 | */
|
45 | import: (collections: SeederCollection[], partialConfig?: DeepPartial<SeederConfig> | undefined) => Promise<void>;
|
46 | }
|