jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
876 B

5 years ago
'use strict';
const configs = require(__dirname+'/../getconfig.js')()
, { MongoClient, ObjectId, Int32 } = require('mongodb')
, { migrateVersion } = require(__dirname+'/../package.json')
5 years ago
module.exports = {
connect: async () => {
if (module.exports.client) {
throw new Error('Mongo already connected');
}
module.exports.client = await MongoClient.connect(configs.dbURL, {
useNewUrlParser: true,
useUnifiedTopology: true
});
module.exports.db = module.exports.client.db(configs.dbName);
5 years ago
},
checkVersion: async() => {
const currentVersion = await module.exports.db
.collection('version')
.findOne({ '_id': 'version' })
.then(res => res.version);
if (currentVersion < migrateVersion) {
console.error('Your migration version is out-of-date. Run `gulp migrate` to update.');
process.exit(1);
}
},
ObjectId,
NumberInt: Int32,
5 years ago
}