2021-09-25 17:47:05 +02:00
|
|
|
import betterSqlite3 from 'better-sqlite3'
|
|
|
|
import mongoose from 'mongoose'
|
|
|
|
|
|
|
|
const sqlite = new betterSqlite3('ddnet.sqlite', { readonly: true })
|
2021-09-26 18:06:45 +02:00
|
|
|
|
|
|
|
function initMongo() {
|
|
|
|
mongoose.connect(
|
|
|
|
process.env.MONGO_URI,
|
|
|
|
{
|
|
|
|
useNewUrlParser: true,
|
|
|
|
useUnifiedTopology: true
|
|
|
|
},
|
|
|
|
() => "Connected to mongodb!"
|
|
|
|
)
|
|
|
|
}
|
2021-09-25 17:47:05 +02:00
|
|
|
|
|
|
|
function getAllMaps(player) {
|
|
|
|
const stmt = sqlite.prepare('SELECT Name, Map, Time, Time, Timestamp, Server FROM race WHERE Name = ?')
|
|
|
|
return stmt.all(player)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2021-09-26 18:06:45 +02:00
|
|
|
initMongo,
|
2021-09-25 17:47:05 +02:00
|
|
|
getAllMaps
|
|
|
|
}
|