Bootstrap geo graph collections
All checks were successful
Build and deploy Docker image / build (push) Successful in 37s

This commit is contained in:
Ruslan Bakiev
2026-06-02 09:25:52 +07:00
parent 3e16b50c65
commit 7476e61d0b

View File

@@ -17,6 +17,19 @@ export function getDb(): Database {
export async function ensureGraph(): Promise<void> {
const db = getDb()
const nodes = db.collection('nodes')
if (!(await nodes.exists())) {
console.log('Creating collection: nodes')
await db.createCollection('nodes')
}
const edges = db.collection('edges')
if (!(await edges.exists())) {
console.log('Creating edge collection: edges')
await db.createEdgeCollection('edges')
}
const graphs = await db.listGraphs()
if (graphs.some(g => g.name === 'optovia_graph')) return