mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-11 08:17:29 -05:00
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
const mongoose = require("mongoose");
|
|
const System = require("../models/system");
|
|
|
|
|
|
|
|
// -------------------------------------------
|
|
|
|
exports.getUserSystems = function(_id) {
|
|
console.log("Listing Systems for: " + _id);
|
|
System.find(
|
|
{
|
|
userId: mongoose.Types.ObjectId(_id)
|
|
},
|
|
function(err, systems) {
|
|
if (err) {
|
|
console.error("Error - ListSystems: " + err);
|
|
return({ success: false, message: err });
|
|
}
|
|
|
|
|
|
var returnSys = systems.map(obj => {
|
|
var rObj = (({
|
|
name,
|
|
shortName,
|
|
description,
|
|
systemType,
|
|
city,
|
|
state,
|
|
county,
|
|
country,
|
|
userId,
|
|
key,
|
|
planType,
|
|
showScreenName
|
|
}) => ({
|
|
name,
|
|
shortName,
|
|
description,
|
|
systemType,
|
|
city,
|
|
state,
|
|
county,
|
|
country,
|
|
userId,
|
|
key,
|
|
planType,
|
|
showScreenName
|
|
}))(obj);
|
|
rObj.id = obj._id;
|
|
return rObj;
|
|
});
|
|
|
|
|
|
return({ success: true, systems: returnSys });
|
|
}
|
|
);
|
|
}
|
|
|
|
exports.listSystems = function(req, res, next) {
|
|
return listSystems(req.user._id);
|
|
}
|
|
|