Work on dbAccess services
This commit is contained in:
parent
cea62fc98e
commit
4f050c1879
@ -75,7 +75,7 @@ The app is designed to be run within Kubernetes or within a Docker container, as
|
||||
|OWL_DB_PASS|twittwoo|NO|Database Password - Do not leave as default in production|
|
||||
|OWL_DB_NAME|owlboard|NO|Database Name|
|
||||
|OWL_DB_PORT|27017|NO|Database Server Port|
|
||||
|OWL_DB_HOST|database|NO|Database Server Host|
|
||||
|OWL_DB_HOST|localhost|NO|Database Server Host|
|
||||
|OWL_LDB_KEY||YES|National Rail LDBWS API Key|
|
||||
|OWL_LDB_SVKEY||NO|National Rail LDBSVWS API Key|
|
||||
|OWL_LDB_CORPUSUSER||YES|Network Rail CORPUS API Username|
|
||||
|
@ -1,25 +0,0 @@
|
||||
// General DB Access aswell as dbInit tests etc.
|
||||
|
||||
const dbUser = process.env.OWL_DB_USER || "owl"
|
||||
const dbPass = process.env.OWL_DB_PASS || "twittwoo"
|
||||
const dbName = process.env.OWL_DB_NAME || "owlboard"
|
||||
const dbPort = process.env.OWL_DB_PORT || 27017
|
||||
const dbHost = process.env.OWL_DB_HOST || "database"
|
||||
|
||||
const { MongoClient } = require('mongodb');
|
||||
|
||||
async function getCrs(tiploc) {
|
||||
|
||||
}
|
||||
|
||||
async function getTiploc(crs) {
|
||||
|
||||
}
|
||||
|
||||
async function checkCrs(crs) {
|
||||
|
||||
}
|
||||
|
||||
module.export = {
|
||||
|
||||
}
|
32
src/services/dbAccess.services.js
Normal file
32
src/services/dbAccess.services.js
Normal file
@ -0,0 +1,32 @@
|
||||
const dbUser = process.env.OWL_DB_USER || "owl"
|
||||
const dbPass = process.env.OWL_DB_PASS || "twittwoo"
|
||||
const dbName = process.env.OWL_DB_NAME || "owlboard"
|
||||
const dbPort = process.env.OWL_DB_PORT || 27017
|
||||
const dbHost = process.env.OWL_DB_HOST || "localhost"
|
||||
const uri = `mongodb://${dbUser}:${dbPass}@${dbHost}:${dbPort}`;
|
||||
|
||||
const { MongoClient } = require('mongodb');
|
||||
|
||||
const client = new MongoClient(uri);
|
||||
const db = client.db(dbName);
|
||||
|
||||
async function put(data,collection) {
|
||||
await client.connect()
|
||||
var coll = db.collection(collection);
|
||||
var result = coll.insertMany(data);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function getCrs(tiploc) {
|
||||
|
||||
}
|
||||
|
||||
async function checkCrs(crs) {
|
||||
|
||||
}
|
||||
|
||||
module.export = {
|
||||
put,
|
||||
getCrs,
|
||||
checkCrs
|
||||
}
|
@ -15,8 +15,7 @@ const gz = require('node-gzip')
|
||||
const corpusUser = process.env.OWL_LDB_CORPUSUSER
|
||||
const corpusPass = process.env.OWL_LDB_CORPUSPASS
|
||||
|
||||
async function initSubset() {
|
||||
var allCorpus = await initAll()
|
||||
async function initSubset(allCorpus) {
|
||||
var cleanCorpus = await clean(allCorpus)
|
||||
return cleanCorpus
|
||||
}
|
||||
|
Reference in New Issue
Block a user