"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MonitorMongos = void 0;
var mongo_manager_1 = require("../managers/mongo.manager");
var resolveio_server_app_1 = require("../resolveio-server-app");
var schema = {
    _id: {
        type: String,
        optional: true
    },
    metadata: {
        type: Object
    },
    'metadata.client': {
        type: String
    },
    'metadata.instance': {
        type: String
    },
    date: {
        type: Date
    },
    method: {
        type: String
    },
    doc_collection: {
        type: String
    },
    duration: {
        type: Number
    },
    query: {
        type: String
    }
};
exports.MonitorMongos = null;
initializeCollection();
function initializeCollection() {
    if (resolveio_server_app_1.ResolveIOServer && resolveio_server_app_1.ResolveIOServer.getMainDB() && mongo_manager_1.MongoManagerModel) {
        var model = mongo_manager_1.MongoManagerModel.create({
            collectionName: 'monitor-mongos',
            schema: schema,
            useVersionCollection: false,
            useReportBuilder: false,
            reportBuilderLookupTables: [],
            timestamps: false,
            createLogs: false,
            checkSchema: false,
            collectionOptions: {
                timeseries: {
                    timeField: 'date',
                    granularity: 'seconds',
                    metaField: 'metadata'
                },
                expireAfterSeconds: 60 * 60 * 24 * 3
            },
            skipCache: true,
            bypassSession: true
        });
        exports.MonitorMongos = model.collection_main;
        exports.MonitorMongos.createIndex({ 'metadata.client': 1, date: 1 });
        exports.MonitorMongos.createIndex({ 'metadata.client': 1, 'metadata.instance': 1, date: 1 });
    }
    else {
        setImmediate(function () {
            initializeCollection();
        });
    }
}

//# sourceMappingURL=monitor-mongo.collection.js.map
