added selfhosted mongo option

This commit is contained in:
2023-08-13 14:33:49 +02:00
parent fcabc328d0
commit ecea682fdd
6 changed files with 246 additions and 143 deletions

View File

@ -3,18 +3,34 @@ const { EmbedBuilder } = require('discord.js');
const mongoose = require('mongoose');
const wolfcount = require('../../models/wolfcount');
const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`
// const dblocation = process.env.DBLOCATION
// if (dblocation === 'selfhosted') {
mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('');
console.log(`Connected to the database`);
}).catch((error) => {
console.log(`Failed to connect to the database`);
console.log(error);
});
// await mongoose.connect('mongodb://127.0.0.1:27017/wolfcounter', {
// useNewUrlParser: true,
// useUnifiedTopology: true
// }).then(() => {
// console.log('');
// console.log(`Connected to the database`);
// }).catch((error) => {
// console.log(`Failed to connect to the selfhosted database`);
// console.log(error);
// });
// } if (dblocation === 'cloud') {
// await mongoose.connect(`mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`, {
// useNewUrlParser: true,
// useUnifiedTopology: true
// }).then(() => {
// console.log('');
// console.log(`Connected to the database`);
// }).catch((error) => {
// console.log(`Failed to connect to the database`);
// console.log(error);
// });
// } else {
// console.error(`Failed to connect to the database, it is possible that the host option is not available`);
// }
// setInterval(function() {
// // Find a document by validation