"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadReportBuilderDashboardBuilderPublications = loadReportBuilderDashboardBuilderPublications;
var simpl_schema_1 = require("simpl-schema");
var report_builder_dashboard_builder_collection_1 = require("../collections/report-builder-dashboard-builder.collection");
function loadReportBuilderDashboardBuilderPublications(subscriptionManager) {
    subscriptionManager.publications({
        reportbuilderdashboards: {
            function: function () {
                return report_builder_dashboard_builder_collection_1.ReportBuilderDashboardBuilders.find({}, { sort: { name: 1 } });
            },
            collections: ['report-builder-dashboard-builders']
        },
        reportbuilderdashboardWithId: {
            check: new simpl_schema_1.default({
                id_dashboard: {
                    type: String
                }
            }),
            function: function (id_dashboard) {
                return report_builder_dashboard_builder_collection_1.ReportBuilderDashboardBuilders.aggregate([
                    {
                        $match: {
                            _id: id_dashboard
                        }
                    },
                    {
                        $lookup: {
                            from: 'report-builder-reports',
                            localField: 'report_rows.report_columns.id_report',
                            foreignField: '_id',
                            as: 'dbReportBuilderReports'
                        }
                    }
                ]);
            },
            collections: ['report-builder-dashboard-builders']
        }
    });
}

//# sourceMappingURL=report-builder-dashboard-builders.js.map
