"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const typeorm_1 = require("typeorm");
const entities_1 = require("../../../entities");
exports.joinGroup = {
    async joinGroup(_, { id, boardIds }) {
        const repository = typeorm_1.getRepository(entities_1.Group);
        const group = await repository.findOne({ id });
        const boardRepository = typeorm_1.getRepository(entities_1.Board);
        await boardIds.forEach(async (boardId) => {
            let board = await boardRepository.findOne({ id: boardId });
            board.group = group;
            await boardRepository.save(board);
        });
        return await repository.findOne({ id }, {
            relations: ['boards']
        });
    }
};
//# sourceMappingURL=join-group.js.map