UNPKG

1.97 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.mergeCollectionReadingOptions = exports.defaultCollectionReadingOptions = exports.mergeSeederConfig = exports.defaultSeederConfig = void 0;
4const extend = require("extend");
5const database_1 = require("./database");
6/**
7 * Stores default configuration for database seeding.
8 */
9exports.defaultSeederConfig = {
10 database: database_1.defaultDatabaseConfigObject,
11 databaseReconnectTimeout: 10000,
12 dropDatabase: false,
13 dropCollections: false,
14 removeAllDocuments: false,
15};
16/**
17 * Merges configuration for database seeding.
18 *
19 * @param partial Partial config object. If not specified, returns a default config object.
20 * @param previous Previous config object. If not specified, uses a default config object as a base.
21 */
22const mergeSeederConfig = (partial, previous) => {
23 const source = previous ? previous : exports.defaultSeederConfig;
24 if (!partial) {
25 return source;
26 }
27 const config = {};
28 return extend(true, config, source, partial);
29};
30exports.mergeSeederConfig = mergeSeederConfig;
31/**
32 * Stores default collection reading configuration values.
33 */
34exports.defaultCollectionReadingOptions = {
35 extensions: ['json', 'js', 'cjs'],
36 ejsonParseOptions: {
37 relaxed: true,
38 },
39 transformers: [],
40};
41/**
42 * Merges configuration for collection reading.
43 *
44 * @param partial Partial config object. If not specified, returns a default config object.
45 * @param previous Previous config object. If not specified, uses a default config object as a base.
46 */
47const mergeCollectionReadingOptions = (partial, previous) => {
48 const source = previous ? previous : exports.defaultCollectionReadingOptions;
49 if (!partial) {
50 return source;
51 }
52 const config = {};
53 return extend(true, config, source, partial);
54};
55exports.mergeCollectionReadingOptions = mergeCollectionReadingOptions;
56//# sourceMappingURL=config.js.map
\No newline at end of file