当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript typeorm.getConnection函数代码示例

本文整理汇总了TypeScript中typeorm.getConnection函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getConnection函数的具体用法?TypeScript getConnection怎么用?TypeScript getConnection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getConnection函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: editAdmin

    public async editAdmin(attributes: AdminFormInterface): Promise<boolean> {
        const formData = await this.checkForm(attributes, 'edit');

        if (!formData) {
            return false;
        }

        try {
            const admin = await getConnection().getRepository(MoAdmins)
                .findOne({
                    id: attributes.id
                });

            if (attributes.password) {
                const convertedPassword = await Admins.passwordConvert(attributes.password);

                admin.password = convertedPassword;
            }

            admin.login = attributes.login;
            admin.level = attributes.level;
            admin.customAccess = JSON.stringify(attributes.permissions);

            await getConnection().getRepository(MoAdmins).save(admin);
        } catch (error) {
            console.error(error);

            return false;
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:32,代码来源:admins.ts

示例2: deleteAdmin

    public async deleteAdmin(id: number): Promise<boolean> {
        const admin = await this.getAdmin(id);

        if (admin.id === this.user.id) {
            this.message += 'You can not delete yourself';

            return false;
        } else if (admin.level >= this.user.level) {
            this.message += 'Denied. Access level is low, you can not delete this admin';

            return false;
        }

        try {
            const label = await getConnection().getRepository(MoAdmins)
                .findOne({
                    id: id
                });

            label.deleted = true;

            await getConnection().getRepository(MoAdmins).save(label);
        } catch (error) {
            console.error(error);

            return false;
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:30,代码来源:admins.ts

示例3: editPage

    public async editPage(attributes: PagesFormInterface): Promise<boolean> {
        const formData = await this.checkForm(attributes);

        if (!formData) {
            return false;
        }

        try {
            const page: MoPages = await getConnection().getRepository(MoPages)
                .findOne({
                    id: attributes.id
                });

            page.title = attributes.title;
            page.metaTitle = attributes.metaTitle;
            page.metaDescription = attributes.metaDescription;
            page.link = attributes.link;
            page.text = attributes.text;
            page.enabled = attributes.enabled;

            await getConnection().getRepository(MoPages).save(page);
        } catch (error) {
            console.error(error);

            return false;
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:29,代码来源:pages.ts

示例4: editLabel

    public async editLabel(attributes: LabelsFormInterface): Promise<boolean> {
        const formData = await this.checkForm(attributes, 'edit');

        if (!formData) {
            return false;
        }

        try {
            const label = await getConnection().getRepository(MoLabels)
                .findOne({
                    id: attributes.id
                });

            label.name = attributes.name;
            label.output = attributes.output;

            await getConnection().getRepository(MoLabels).save(label);
        } catch (error) {
            console.error(error);

            return false;
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:25,代码来源:labels.ts

示例5: cleanAuth

    static async cleanAuth(user: MoAdmins): Promise<boolean> {
        const response = await getConnection().getRepository(MoUsersAuth)
            .find({
                user: user
            });

        if (response) {
            await getConnection().getRepository(MoUsersAuth).remove(response);
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:12,代码来源:logout.ts

示例6: addAdmin

    public async addAdmin(attributes: AdminFormInterface): Promise<boolean> {
        const formData = await this.checkForm(attributes, 'add');

        if (!formData) {
            return false;
        }

        const convertedPassword = await Admins.passwordConvert(attributes.password);
        const newAdmin = new MoAdmins();

        newAdmin.login = attributes.login;
        newAdmin.password = convertedPassword;
        newAdmin.level = attributes.level;
        newAdmin.customAccess = JSON.stringify(attributes.permissions);

        try {
            await getConnection().getRepository(MoAdmins).save(newAdmin);
        } catch (error) {
            console.error(error);

            return false;
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:25,代码来源:admins.ts

示例7: getLabels

    public async getLabels(attributes: GetLabelInterface): Promise<Array<LabelsFormInterface>> {
        const returnLabels = [];

        try {
            // Fetching previous attempts to login
            const labels = await getConnection().getRepository(MoLabels)
                .find({
                    where: {
                        siteId: attributes.siteId,
                        deleted: false
                    },
                    order: {
                        name: 'ASC'
                    }
                });

            for (const label of labels) {
                returnLabels.push({
                    id: label.id,
                    name: label.name,
                    output: this.stripLabel(label.output)
                });
            }
        } catch (error) {
            console.error(error);
        }

        return returnLabels;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:29,代码来源:labels.ts

示例8: createAndSaveTransaction

  async createAndSaveTransaction(transactionData: any, status: string, blockData?: any ): Promise<void> {
    const txRepo = getConnection().getMongoRepository(Transaction);
    const type = this.getTxTypeByData(transactionData);
    const { from, to, jcrAmount } = this.getFromToJcrAmountByTxDataAndType(transactionData, type);

    let timestamp;
    let blockNumber;

    if (blockData) {
      timestamp = blockData.timestamp;
      blockNumber = blockData.number;
    } else {
      timestamp = Math.round(+new Date() / 1000);
    }

    const transformedTxData = {
      transactionHash: transactionData.hash,
      from,
      type,
      to,
      ethAmount: this.web3.utils.fromWei(transactionData.value).toString(),
      jcrAmount: jcrAmount,
      status,
      timestamp,
      blockNumber
    };

    const txToSave = txRepo.create(transformedTxData);
    await txRepo.save(txToSave);
  }
开发者ID:Norestlabs-Mariya,项目名称:backend-ico-dashboard,代码行数:30,代码来源:transaction.service.ts

示例9: getPages

    public async getPages(attributes: GetPageInterface): Promise<Array<PagesFormInterface>> {
        const returnPages = [];

        try {
            // Fetching previous attempts to login
            const pages: Array<MoPages> = await getConnection().getRepository(MoPages)
                .find({
                    where: {
                        siteId: attributes.siteId,
                        deleted: false
                    },
                    order: {
                        title: 'ASC'
                    }
                });

            for (const page of pages) {
                returnPages.push({
                    id: page.id,
                    title: page.title,
                    metaTitle: page.metaTitle,
                    metaDescription: page.metaDescription,
                    link: page.link,
                    text: page.text,
                    enabled: page.enabled
                });
            }
        } catch (error) {
            console.error(error);
        }

        return returnPages;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:33,代码来源:pages.ts

示例10: getLabel

    public async getLabel(attributes: GetLabelInterface): Promise<LabelsFormInterface> {
        let returnLabel = null;

        try {
            // Fetching previous attempts to login
            const label = await getConnection().getRepository(MoLabels)
                .findOne({
                    siteId: attributes.siteId,
                    deleted: false,
                    id: attributes.id
                });

            if (label) {
                returnLabel = {
                    id: label.id,
                    name: label.name,
                    output: label.output
                };
            }
        } catch (error) {
            console.error(error);
        }

        return returnLabel;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:25,代码来源:labels.ts


注:本文中的typeorm.getConnection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。