trying an earlier version

This commit is contained in:
Luke Berndt
2023-04-11 20:20:30 -04:00
parent 60944e4d4f
commit dc1b190b5f
4 changed files with 16 additions and 8 deletions

View File

@@ -1,8 +1,15 @@
const Group = require("../models/group");
exports.get_groups = async function (req, res) {
const grp_results = await Group.find({ shortName: req.params.shortName.toLowerCase()}).sort("position").exec();
process.nextTick(async function () {
const grp_results = await Group.find({ shortName: req.params.shortName.toLowerCase()}).sort("position").catch(err => {
console.error(err);
res.status(500);
res.json({ success: false, message: err });
return;
});
res.contentType('json');
res.send(JSON.stringify(grp_results));
});
}

View File

@@ -1,7 +1,13 @@
const Talkgroup = require("../models/talkgroup");
exports.get_talkgroups = async function (req, res) {
const tg_results = await Talkgroup.find({ 'shortName': req.params.shortName.toLowerCase()})
const tg_results = await Talkgroup.find({ 'shortName': req.params.shortName.toLowerCase()}).catch(err => {
console.error(err);
res.status(500);
res.json({ success: false, message: err });
return;
});
var talkgroups = {};
for (var tg in tg_results) {
talkgroups[tg_results[tg].num] = tg_results[tg];

View File

@@ -51,19 +51,14 @@ const connect = async () => {
console.log(mongoose.connection.readyState); //logs 0
mongoose.connection.on('connecting', () => {
console.log('Mongoose is connecting')
console.log(mongoose.connection.readyState); //logs 2
});
mongoose.connection.on('connected', () => {
console.log('Mongoose is connected');
console.log(mongoose.connection.readyState); //logs 1
});
mongoose.connection.on('disconnecting', () => {
console.log('Mongoose is disconnecting');
console.log(mongoose.connection.readyState); // logs 3
});
// Connect to a MongoDB server running on 'localhost:27017' and use the
// 'test' database.
await mongoose.connect(mongoUrl, { useNewUrlParser: true, useUnifiedTopology: true });
console.log("All Done");
}

View File

@@ -24,7 +24,7 @@
"get-folder-size": "^4.0.0",
"mkdirp": "^2.1.6",
"mongodb": "5.2.0",
"mongoose": "7.0.3",
"mongoose": "7.0.0",
"multer": "1.3.0",
"node-ffprobe": "https://github.com/ListenerApproved/node-ffprobe",
"node-schedule": "2.1.1",