Added a own aggregates file

- Aggregate and project missing fields
- Updated how channels are created, to add the new fields
This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-28 11:13:49 +02:00
parent 3102893e15
commit 693e30f273
5 changed files with 151 additions and 127 deletions

View File

@@ -230,7 +230,16 @@ function conf_function(params, coll, guid, offline, socket) {
$set:obj
}, function(err, docs){
Functions.setSessionUserPass(Functions.getSession(socket), obj["userpass"], coll, function() {
db.collection(coll + "_settings").find(function(err, docs){
db.collection(coll + "_settings").aggregate([
{
"$match": {
id: "config"
}
},
{
"$project": projects.toShowConfig
},
], function(err, docs){
if(docs[0].adminpass !== "") docs[0].adminpass = true;
if(docs[0].hasOwnProperty("userpass") && docs[0].userpass != "") docs[0].userpass = true;
else docs[0].userpass = false;