Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syncIndexes to all models JIC #1750

Merged
merged 1 commit into from
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var chain = require('./libs/debug').chain;
var path = require('path');
var crypto = require('crypto');

var events = require('events');
events.EventEmitter.defaultMaxListeners = 15;

var express = require('express');
var toobusy = require('toobusy-js');
var statusCodePage = require('./libs/templateHelpers').statusCodePage;
Expand Down
16 changes: 16 additions & 0 deletions models/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,20 @@ var commentSchema = new Schema({

var Comment = mongoose.model('Comment', commentSchema);

Comment.syncIndexes(function () {
Comment.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Comment indexes:\n', aIndexes);
}).catch(console.error);
});

Comment.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Comment model');
}
});

exports.Comment = Comment;
16 changes: 16 additions & 0 deletions models/discussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ var discussionSchema = new Schema({

var Discussion = mongoose.model('Discussion', discussionSchema);

Discussion.syncIndexes(function () {
Discussion.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Discussion indexes:\n', aIndexes);
}).catch(console.error);
});

Discussion.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Discussion model');
}
});

exports.Discussion = Discussion;
16 changes: 16 additions & 0 deletions models/flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ var flagSchema = new Schema({

var Flag = mongoose.model('Flag', flagSchema);

Flag.syncIndexes(function () {
Flag.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Flag indexes:\n', aIndexes);
}).catch(console.error);
});

Flag.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Flag model');
}
});

exports.Flag = Flag;
16 changes: 16 additions & 0 deletions models/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ var groupSchema = new Schema({

var Group = mongoose.model('Group', groupSchema);

Group.syncIndexes(function () {
Group.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Group indexes:\n', aIndexes);
}).catch(console.error);
});

Group.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Group model');
}
});

exports.Group = Group;
16 changes: 16 additions & 0 deletions models/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@ var removeSchema = new Schema({

var Remove = mongoose.model('Remove', removeSchema);

Remove.syncIndexes(function () {
Remove.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Remove indexes:\n', aIndexes);
}).catch(console.error);
});

Remove.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Remove model');
}
});

exports.Remove = Remove;
16 changes: 16 additions & 0 deletions models/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,20 @@ var strategySchema = new Schema({

var Strategy = mongoose.model('Strategy', strategySchema);

Strategy.syncIndexes(function () {
Strategy.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Strategy indexes:\n', aIndexes);
}).catch(console.error);
});

Strategy.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Strategy model');
}
});

exports.Strategy = Strategy;
16 changes: 16 additions & 0 deletions models/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ var syncSchema = new Schema({

var Sync = mongoose.model('Sync', syncSchema);

Sync.syncIndexes(function () {
Sync.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Sync indexes:\n', aIndexes);
}).catch(console.error);
});

Sync.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Sync model');
}
});

exports.Sync = Sync;
16 changes: 16 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,21 @@ var userSchema = new Schema({

var User = mongoose.model('User', userSchema);

User.syncIndexes(function () {
User.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('User indexes:\n', aIndexes);
}).catch(console.error);
});

User.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for User model');
}
});

exports.User = User;

16 changes: 16 additions & 0 deletions models/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,20 @@ var voteSchema = new Schema({

var Vote = mongoose.model('Vote', voteSchema);

Vote.syncIndexes(function () {
Vote.collection.getIndexes({
full: true
}).then(function(aIndexes) {
console.log('Vote indexes:\n', aIndexes);
}).catch(console.error);
});

Vote.on('index', function (aErr) {
if (aErr) {
console.error(aErr);
} else {
console.log('Index event triggered/trapped for Vote model');
}
});

exports.Vote = Vote;