Bootstrap geo graph collections
All checks were successful
Build and deploy Docker image / build (push) Successful in 37s
All checks were successful
Build and deploy Docker image / build (push) Successful in 37s
This commit is contained in:
13
src/db.ts
13
src/db.ts
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user