2 Commity e3ae99a397 ... 5415638fb0

Autor SHA1 Wiadomość Data
  FAMBL 5415638fb0 Replace fromEnzo to default. 1 rok temu
  FAMBL f38f63b3e2 More fixes for StorageLocation. 1 rok temu
4 zmienionych plików z 14 dodań i 8 usunięć
  1. 1 1
      index.ts
  2. 11 5
      services/dataprep.service.ts
  3. 1 1
      test/test2.ts
  4. 1 1
      test/test3.ts

+ 1 - 1
index.ts

@@ -9,7 +9,7 @@ const mongoose = require('mongoose');
 app.use(bodyParser.urlencoded({ extended: false }))
 app.use(bodyParser.json());
 
-mongoose.connect('mongodb://192.168.100.59:27017/fromEnzo', { useNewUrlParser: true, useUnifiedTopology: true })
+mongoose.connect('mongodb://192.168.100.59:27017/default', { useNewUrlParser: true, useUnifiedTopology: true })
     .then(() => console.log('Database connected'))
     .catch(err => console.log(err));
 

+ 11 - 5
services/dataprep.service.ts

@@ -1,7 +1,7 @@
 import mongoose, { Model, Mongoose } from "mongoose";
 import { Observable, Subject } from "rxjs";
 import * as fs from 'fs'
-import { Storage } from "./query.service";
+import { Storage, StorageLocation } from "./query.service";
 
 
 export class DataPrepService {
@@ -14,11 +14,17 @@ export class DataPrepService {
         if (storage.type == `File`) {
             this.streamFileData(storage, dataFromStorage)
         } else {
-            this.streamMongoData(storage, dataFromStorage)
+            if (storage.type != `observable`)
+            {
+                this.streamMongoData(storage as StorageLocation, dataFromStorage)
+            }
+            else{
+                //....
+            }
         }
     }
 
-    private streamMongoData(storage: Storage, subjectStream: Subject<any>) {
+    private streamMongoData(storage: StorageLocation, subjectStream: Subject<any>) {
         this.connectMongo(storage).then(() => {
             let message: Model<any> = this.MongooseConnection.model('Message', require('../types/message.schema'))
             let stream = message.find().cursor()
@@ -29,7 +35,7 @@ export class DataPrepService {
         })
     }
 
-    private streamFileData(storage: Storage, dataFromStorage: Subject<any>) {
+    private streamFileData(storage: StorageLocation, dataFromStorage: Subject<any>) {
         let data = fs.readFileSync(storage.url, 'utf-8')
         let dataJson = JSON.parse(data)
         let count = 0
@@ -45,7 +51,7 @@ export class DataPrepService {
     }
 
     // Conect to designated storage destination
-    private async connectMongo(storage: Storage) {
+    private async connectMongo(storage: StorageLocation) {
         return new Promise((resolve, reject) => {
             try {
                 console.log(`Connecting to ${storage.url}`)

+ 1 - 1
test/test2.ts

@@ -12,7 +12,7 @@ let query = new SearchService()
 
 let mongoStorage : Storage = {
     type: `MongoDB`,
-    url: `mongodb://192.168.100.59:27017/fromEnzo`
+    url: `mongodb://192.168.100.59:27017/default`
 }
 
 // Array inquiry: should return mutiple data

+ 1 - 1
test/test3.ts

@@ -10,7 +10,7 @@ let connectionStatus = 0
 
 let mongoStorage: any = {
     type: `MongoDB`,
-    url: `mongodb://192.168.100.59:27017/fromEnzo`
+    url: `mongodb://192.168.100.59:27017/default`
 }
 
 let testSubject: Subject<any> = new Subject()