Files
overleaf/services/history-v1/storage/lib/mongodb.js
Brian Gough cc7f0c1b9b Merge pull request #29321 from overleaf/bg-ignore-deleted-projects-in-history-backup
handle deleted projects in history-v1 backup worker

GitOrigin-RevId: f4392045074248137f15d082d922c18b1ef9232f
2025-10-28 09:05:34 +00:00

41 lines
1.1 KiB
JavaScript

// @ts-check
const Metrics = require('@overleaf/metrics')
const MongoUtils = require('@overleaf/mongo-utils')
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')
const deletedProjects = db.collection('deletedProjects')
// 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)
async function cleanupTestDatabase() {
await MongoUtils.cleanupTestDatabase(client)
}
module.exports = {
client,
db,
chunks,
blobs,
globalBlobs,
projects,
deletedProjects,
shardedBlobs,
backedUpBlobs,
cleanupTestDatabase,
}