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


TypeScript transaction.start方法代码示例

本文整理汇总了TypeScript中objection.transaction.start方法的典型用法代码示例。如果您正苦于以下问题:TypeScript transaction.start方法的具体用法?TypeScript transaction.start怎么用?TypeScript transaction.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在objection.transaction的用法示例。


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

示例1: test

            test("creates artist names", async () => {
                expect.assertions(9);

                const trx = await transaction.start(Artist.knex());

                try {
                    let artist: Artist;

                    artist = await createArtistAndArtistNames(DEFAULT_PAYLOAD.input, trx);
                    artist = await artist.$loadRelated("names(orderById)", {
                        orderById: (builder) => builder.orderBy("id"),
                    }, trx);

                    const names = artist.names;
                    if (!names) { return; }

                    expect(names.length).toBe(2);

                    expect(names[0].is_default).toBe(false);
                    expect(names[0].is_original).toBe(true);
                    expect(names[0].locale).toBe("ko");
                    expect(names[0].name).toBe("루나");

                    expect(names[1].is_default).toBe(true);
                    expect(names[1].is_original).toBe(false);
                    expect(names[1].locale).toBe("ko-Latn");
                    expect(names[1].name).toBe("Luna");
                } finally {
                    await trx.rollback();
                }
            });
开发者ID:zaeleus,项目名称:lp-api,代码行数:31,代码来源:Mutation.test.ts

示例2: test

        test("updates an existing artist record", async () => {
            expect.assertions(9);

            const trx = await transaction.start(Artist.knex());

            try {
                let artist = await createArtist({}, trx);

                artist = await artist.update({
                    country: "GB",
                    disambiguation: "group",
                    endedOn: PartialDate.parse("2017"),
                    kind: ArtistKind.Group,
                }, trx);

                expect(artist.country).toBe("GB");
                expect(artist.disambiguation).toBe("group");
                expect(artist.ended_on_year).toBe(2017);
                expect(artist.ended_on_month).toBeNull();
                expect(artist.ended_on_day).toBeNull();
                expect(artist.kind).toBe(ArtistKind.Group);
                expect(artist.started_on_year).toBe(1990);
                expect(artist.started_on_month).toBe(8);
                expect(artist.started_on_day).toBeNull();
            } finally {
                await trx.rollback();
            }
        });
开发者ID:zaeleus,项目名称:lp-api,代码行数:28,代码来源:Artist.test.ts

示例3: test

    test("#update", async () => {
        expect.assertions(5);

        const trx = await transaction.start(Artist.knex());

        try {
            const artist = await createArtist({}, trx);
            let name = await createArtistName({ artistId: artist.id.toString() }, trx);

            name = await name.update({
                isDefault: false,
                isOriginal: false,
                locale: "ko-Latn",
                name: "Exy",
            }, trx);

            expect(name.artist_id).toBe(artist.id);
            expect(name.isDefault).toBe(false);
            expect(name.isOriginal).toBe(false);
            expect(name.locale).toBe("ko-Latn");
            expect(name.name).toBe("Exy");
        } finally {
            await trx.rollback();
        }
    });
开发者ID:zaeleus,项目名称:lp-api,代码行数:25,代码来源:ArtistName.test.ts


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