Skip to content

Commit

Permalink
update connect-mongo, handle mongo deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
btouellette committed Aug 3, 2020
1 parent 9b2c4f7 commit f5c7710
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/gameserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ var twitter = new twit({

module.exports = function(server, sessionStore) {
// if the tile db is empty load in the tiles,
Tile.count({ expansion: 'base-game' }, function(err, count) {
Tile.countDocuments({ expansion: 'base-game' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesBase();
}
});
Tile.count({ expansion: 'inns-and-cathedrals' }, function(err, count) {
Tile.countDocuments({ expansion: 'inns-and-cathedrals' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesIAC();
}
});
Tile.count({ expansion: 'traders-and-builders' }, function(err, count) {
Tile.countDocuments({ expansion: 'traders-and-builders' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesTAB();
}
});
Tile.count({ expansion: 'the-tower' }, function(err, count) {
Tile.countDocuments({ expansion: 'the-tower' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesTT();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"body-parser": "^1.17.2",
"compression": "^1.7.0",
"connect-flash": "^0.1.1",
"connect-mongo": "^1.3.2",
"connect-mongo": "^3.2.0",
"cookie": "^0.3.1",
"cookie-parser": "^1.4.3",
"ejs": "^2.5.7",
Expand Down
3 changes: 3 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ var sessionStore = new MongoStore({
autoReconnect: true
});

mongoose.set('useCreateIndex', true); // handle deprecations: https://mongoosejs.com/docs/deprecations.html
mongoose.set('useNewUrlParser', true);
mongoose.set('useUnifiedTopology', true);
mongoose.plugin(schema => { schema.options.usePushEach = true }); // MongoDB 3.6+ deprecates $pushAll, set flag for mongoose to avoid that operator
mongoose.connect(configDB.url); // connect to our database

Expand Down

0 comments on commit f5c7710

Please sign in to comment.