Browse Source

NeDB integration #85 (#87)

* Add module

* Add database paths

* Initialize databases
pull/1/head
rozetko 6 years ago committed by Alexey Velikiy
parent
commit
7f03d3fafd
  1. 2
      server/package.json
  2. 4
      server/src/config.ts
  3. 6
      server/src/services/data_service.ts

2
server/package.json

@ -23,6 +23,7 @@
"@types/koa": "^2.0.45",
"@types/koa-bodyparser": "^4.2.0",
"@types/koa-router": "^7.0.28",
"@types/nedb": "^1.8.0",
"axios": "^0.18.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
@ -35,6 +36,7 @@
"koa": "^2.5.1",
"koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0",
"nedb": "^1.8.0",
"node-loader": "^0.6.0",
"nodemon": "^1.17.5",
"ts-loader": "^4.4.1",

4
server/src/config.ts

@ -10,6 +10,10 @@ export const ANALYTICS_PATH = path.join(__dirname, '../../analytics');
export const DATA_PATH = path.join(__dirname, '../../data');
export const ANALYTIC_UNITS_DATABASE_PATH = path.join(DATA_PATH, 'analyticUnits.db');
export const METRICS_DATABASE_PATH = path.join(DATA_PATH, 'metrics.db');
export const SEGMENTS_DATABASE_PATH = path.join(DATA_PATH, 'segments.db');
export const DATASETS_PATH = path.join(DATA_PATH, 'datasets');
export const ANALYTIC_UNITS_PATH = path.join(DATA_PATH, 'analytic_units');
export const MODELS_PATH = path.join(DATA_PATH, 'models');

6
server/src/services/data_service.ts

@ -1,7 +1,13 @@
import * as config from '../config'
import * as nedb from 'nedb';
import * as fs from 'fs';
export const db = {
analyticUnits: new nedb({ filename: config.ANALYTIC_UNITS_DATABASE_PATH, autoload: true }),
metrics: new nedb({ filename: config.METRICS_DATABASE_PATH, autoload: true }),
segments: new nedb({ filename: config.SEGMENTS_DATABASE_PATH, autoload: true })
};
// see analytics/pattern_detection_model.py with folders available

Loading…
Cancel
Save