overleaf-cep/services/history-v1/storage/lib/mongodb.js
Andrew Rumble a92a37bc3c Merge pull request #22466 from overleaf/ar-backup-files-when-inserting
[history-v1] backup files when inserting

GitOrigin-RevId: e636bce178604978c6d41c083bf671795d20b5a1
2024-12-13 09:04:54 +00:00

30 lines
879 B
JavaScript

const Metrics = require('@overleaf/metrics')
const config = require('config')
const { MongoClient } = require('mongodb')
const client = new MongoClient(config.mongo.uri)
const db = client.db()
const chunks = db.collection('projectHistoryChunks')
const blobs = db.collection('projectHistoryBlobs')
const globalBlobs = db.collection('projectHistoryGlobalBlobs')
const shardedBlobs = db.collection('projectHistoryShardedBlobs')
const projects = db.collection('projects')
// Temporary collection for tracking progress of backed up old blobs (without a hash).
// The initial sync process will be able to skip over these.
// Schema: _id: projectId, blobs: [Binary]
const backedUpBlobs = db.collection('projectHistoryBackedUpBlobs')
Metrics.mongodb.monitor(client)
module.exports = {
client,
db,
chunks,
blobs,
globalBlobs,
projects,
shardedBlobs,
backedUpBlobs,
}