本文整理汇总了TypeScript中objection.transaction类的典型用法代码示例。如果您正苦于以下问题:TypeScript transaction类的具体用法?TypeScript transaction怎么用?TypeScript transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了transaction类的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类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论