Skip to content

Commit

Permalink
use in memory mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrunic committed Apr 6, 2021
1 parent 78e536b commit b5fdd86
Show file tree
Hide file tree
Showing 4 changed files with 837 additions and 416 deletions.
24 changes: 16 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,24 @@ for (const file of commandFiles) {
bot.commands.set(command.name, command);
}

// mongodb setup with mongoose
mongoose
.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
const { MongoMemoryServer } = require('mongodb-memory-server');


MongoMemoryServer.create({ autoStart: true }).then((mongos) => {
// mongodb setup with mongoose
mongos.getConnectionString().then((uri) => {
mongoose
.connect(uri, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
})
.catch(() => console.log("Ruh Roh!"));

mongoose.connection.once("open", () => console.log("mongoDB connected"));
})
.catch(() => console.log("Ruh Roh!"));

mongoose.connection.once("open", () => console.log("mongoDB connected"));
})

bot.once("ready", () => console.log("Discord Bot Ready"));

Expand Down
Loading

0 comments on commit b5fdd86

Please # to comment.