"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocialNetworkProvidersController = void 0;
const abstract_controller_1 = require("../abstract.controller");
const social_network_provider_model_1 = require("../../models/social-network/social-network-provider.model");
const social_network_provider_method_1 = require("../../methods/social-network/social-network-provider.method");
class SocialNetworkProvidersController extends abstract_controller_1.AbstractController {
    constructor() {
        super(social_network_provider_model_1.SocialNetworkProvidersModel);
        this.methods = new social_network_provider_method_1.SocialNetworkProvidersMethods(social_network_provider_model_1.SocialNetworkProvidersModel);
    }
    async getItems(req, res, next) {
        try {
            const { filter, sort } = this.params.aqp(req.query);
            const [, options] = this.params.optionsPaginate(req);
            let aggregate = this.model.aggregate([
                {
                    $match: filter,
                },
                {
                    $match: { deleted: false },
                },
            ]);
            const data = await this.model.aggregatePaginate({ ...aggregate }, {
                ...options,
                sort,
            });
            res.send(data);
        }
        catch (e) {
            this.params.handleHttpError(res, e);
        }
    }
}
exports.SocialNetworkProvidersController = SocialNetworkProvidersController;
