I'm trying to use the function print in "NoSQL Manager for MongoDB 4.9.10.2" to print the first element of an array. I'm trying to do the following:
var start = ISODate("2018-12-18T03:00:00.000Z");
var end = ISODate("2018-12-19T02:59:59.000Z");
db.moicaTickets.aggregate([
{ $match :
{ asunto:{$exists:true},
asunto: {$ne:null},
tiempos:{$exists:true},
tiempos: {$ne:null},
problemas:{$exists:true},
creado:{$exists:true},
"creado.lastEvent_tc": { $gt: start, $lt: end } }},
{ $project:
{ pFecha: { $dateToString: { format: "%Y-%m-%d", date: "$creado.lastEvent_tc", timezone: "-03:00" } },
asunto: 1,
tiempos: 1,
nroTkt: 1,
losProblemas: { $arrayElemAt: ["$problemas",0]},
primerProblema: "$losProblemas.nombre",
primera: { $arrayElemAt: ["$tiempos",0]}}},
{ $addFields: { "lacola":{ "$toObjectId": "$primera.cola" }}},
{ $lookup:
{
from: "moicaTicketsColas",
localField: "lacola",
foreignField: "_id",
as: "nombreCola"
}}
]).forEach(function(doc){
print(doc.nroTkt+";"+doc.nombreCola.0.arbol+";"+doc.pFecha+";"+doc.asunto.titulo+";"+doc.primerProblema);
})
But i get the next error:
2018-12-19T12:00:06.660-0300 E QUERY [js] SyntaxError: missing ) after argument list @(shell):29:44