1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | exports.CollectionImporter = void 0;
|
13 |
|
14 |
|
15 |
|
16 | class CollectionImporter {
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | constructor(db, collectionInsertManyOptions, log) {
|
24 | this.db = db;
|
25 | this.collectionInsertManyOptions = collectionInsertManyOptions;
|
26 | this.log = log ? log : () => { };
|
27 | }
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 | import(collections) {
|
34 | return __awaiter(this, void 0, void 0, function* () {
|
35 | for (const collection of collections) {
|
36 | yield this.importCollection(collection);
|
37 | }
|
38 | });
|
39 | }
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | importCollection(collection) {
|
46 | return __awaiter(this, void 0, void 0, function* () {
|
47 | this.log(`Inserting ${collection.documents.length} documents into collection ${collection.name}...`);
|
48 | return this.db.insertDocumentsIntoCollection(collection.documents, collection.name, this.collectionInsertManyOptions);
|
49 | });
|
50 | }
|
51 | }
|
52 | exports.CollectionImporter = CollectionImporter;
|
53 |
|
\ | No newline at end of file |