Work on dbAccess services

This commit is contained in:
Fred Boniface 2022-12-21 21:14:52 +00:00
parent cea62fc98e
commit 4f050c1879
4 changed files with 34 additions and 28 deletions

View File

@ -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|

View File

@ -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 = {
}

View 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
}

View File

@ -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
}