2025年8月31日時点での実装
2025/8/31 11:10:00
class PostImportService {
constructor(private readonly src_repository: IPostRepository, private readonly dest_repository: IPostRepository) { }
async import() {
for (let i = 0; i < 100000; i++) {
const batch_size = 10;
const posts = await this.src_repository.list({ take: batch_size, skip: i * batch_size });
if (posts.length === 0) {
break;
}
for (const post of posts) {
const post_in_dest = await this.dest_repository.getByKno(post.kno);
if (post_in_dest.posted_at < post.posted_at) {
this.dest_repository.save(post);
}
}
}
}
}