-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new script to create the collection without using docker init com…
…mands
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require("dotenv").config() | ||
const { connect } = require("../db") | ||
|
||
connect(async db => { | ||
const collections = await db | ||
.listCollections({ name: "indexed_services" }, { nameOnly: true }) | ||
.toArray() | ||
|
||
const indexedServicesDb = collections.some(a => a.name === "indexed_services") | ||
|
||
if (!indexedServicesDb) { | ||
try { | ||
await db.createCollection("indexed_services") | ||
console.log("✅ 'indexed_services' Collection created successfully") | ||
process.exit() | ||
} catch (e) { | ||
console.log(e) | ||
throw e | ||
} | ||
} else { | ||
console.log("✅ 'indexed_services' Collection already exists") | ||
process.exit() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters