dbAccess.services now works
This commit is contained in:
parent
19926dc9aa
commit
5ff40057c3
@ -5,12 +5,23 @@ const dbPort = process.env.OWL_DB_PORT || 27017
|
|||||||
const dbHost = process.env.OWL_DB_HOST || "localhost"
|
const dbHost = process.env.OWL_DB_HOST || "localhost"
|
||||||
const uri = `mongodb://${dbUser}:${dbPass}@${dbHost}:${dbPort}`;
|
const uri = `mongodb://${dbUser}:${dbPass}@${dbHost}:${dbPort}`;
|
||||||
|
|
||||||
import { MongoClient } from 'mongodb';
|
const { MongoClient } = require('mongodb');
|
||||||
|
|
||||||
const client = new MongoClient(uri);
|
const client = new MongoClient(uri);
|
||||||
const db = client.db(dbName);
|
const db = client.db(dbName);
|
||||||
|
|
||||||
async function put(data,collection) {
|
async function putCorpusAll(data){
|
||||||
|
await client.connect();
|
||||||
|
var coll = db.collection("corpusAll");
|
||||||
|
var result = coll.insertMany(data);
|
||||||
|
console.log(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
async function putStations(data){
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
async function putData(data,collection) {
|
||||||
await client.connect()
|
await client.connect()
|
||||||
var coll = db.collection(collection);
|
var coll = db.collection(collection);
|
||||||
var result = coll.insertMany(data);
|
var result = coll.insertMany(data);
|
||||||
@ -25,8 +36,10 @@ async function checkCrs(crs) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.export = {
|
module.exports = {
|
||||||
put,
|
putData,
|
||||||
|
putCorpusAll,
|
||||||
|
putStations,
|
||||||
getCrs,
|
getCrs,
|
||||||
checkCrs
|
checkCrs
|
||||||
}
|
}
|
Reference in New Issue
Block a user