Files
buildpath/frontend/server/utils/mongo.js
vhaudiquet 43968e4cf1
All checks were successful
pipeline / build-and-push-images (push) Successful in 24s
pipeline / deploy (push) Successful in 7s
Added lanes (first try)
2024-11-27 20:59:03 +01:00

18 lines
618 B
JavaScript

import { MongoClient } from 'mongodb'
async function connectToDatabase() {
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
const client = new MongoClient(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@mongo:27017`)
await client.connect()
return client
}
async function fetchLatestPatch(client) {
const database = client.db("patches");
const patches = database.collection("patches");
const latestPatch = await patches.find().limit(1).sort({date:-1}).next()
return latestPatch.patch
}
export {connectToDatabase, fetchLatestPatch}