Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public static void main(String[] args) {
schemaYdbRepository.dropSchema();
schemaYdbRepository.createSchema();
issueYdbRepository.saveAll(List.of(
new TitleAuthor("Ticket 1", "Author 1"),
new TitleAuthor("Ticket 2", "Author 2"),
new TitleAuthor("Ticket 3", "Author 3"))
"Ticket 1",
"Ticket 2",
"Ticket 3"
)
);

var allTickets = issueYdbRepository.findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,19 @@ public List<Issue> findByIds(List<Long> ids) {
/**
* Пакетное добавление нескольких тикетов за один запрос
*/
public void saveAll(List<TitleAuthor> titleAuthors) {
public void saveAll(List<String> issues) {

// Тут описывается структура данных, которая будет служить виртуальной таблицей.
var structType = StructType.of(
"id", PrimitiveType.Int64,
"title", PrimitiveType.Text,
"author", OptionalType.of(PrimitiveType.Text),
"created_at", PrimitiveType.Timestamp
);

var listIssues = Params.of("$args", ListType.of(structType).newValue(
titleAuthors.stream().map(issue -> structType.newValue(
issues.stream().map(issue -> structType.newValue(
"id", PrimitiveValue.newInt64(ThreadLocalRandom.current().nextLong()),
"title", PrimitiveValue.newText(issue.title()),
"author", OptionalType.of(PrimitiveType.Text).newValue(PrimitiveValue.newText(issue.author())),
"title", PrimitiveValue.newText(issue),
"created_at", PrimitiveValue.newTimestamp(Instant.now())
)).toList()
));
Expand All @@ -72,7 +70,6 @@ public void saveAll(List<TitleAuthor> titleAuthors) {
DECLARE $args AS List<Struct<
id: Int64,
title: Text,
author: Text?, -- тут знак вопроса означает, что в Timestamp может быть передан NULL
created_at: Timestamp,
>>;

Expand Down

This file was deleted.