UNPKG

@coko/server

Version:

Reusable server for use by Coko's projects

31 lines 1.45 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getChatChannels = exports.getChatChannel = void 0; const logger_1 = __importDefault(require("../../logger")); const chatChannel_model_1 = __importDefault(require("./chatChannel.model")); const useTransaction_1 = __importDefault(require("../useTransaction")); const constants_1 = require("./constants"); const { CHAT_CHANNEL_CONTROLLER } = constants_1.labels; const getChatChannel = async (id, options = {}) => { try { const { trx, ...restOptions } = options; return (0, useTransaction_1.default)(async (tr) => { logger_1.default.info(`${CHAT_CHANNEL_CONTROLLER} getChatChannel: fetching chat Channel with id ${id}`); return chatChannel_model_1.default.findById(id, { trx: tr, ...restOptions }); }, { trx, passedTrxOnly: true }); } catch (e) { logger_1.default.error(`${CHAT_CHANNEL_CONTROLLER} getChatChannel: ${e.message}`); throw e; } }; exports.getChatChannel = getChatChannel; const getChatChannels = async (where = {}, options = {}) => { const { trx, ...rest } = options; return chatChannel_model_1.default.find(where, { trx, ...rest }); }; exports.getChatChannels = getChatChannels; //# sourceMappingURL=chatChannel.controller.js.map