Feature: `.findMany` & `.saveMany`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rust, typescript
- Lĩnh vực
- api, backend-api-design, databases
Hướng nghiên cứu
Bắt đầu với entity API được inject được mô tả trong proposal và so sánh các hành vi dự kiến của findMany và saveMany với tài liệu tham chiếu findMany của Prisma V2. Xác định ngữ nghĩa của việc đọc hàng loạt, sắp xếp và ghi, sau đó xác định các điểm vào triển khai và kiểm thử liên quan; hoàn thành khi các subgraph có thể thay thế việc tải và lưu entity lặp lại bằng các thao tác này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Proposal
The injected entity API should also expose bulk operations like findMany, saveMany. This seems like a simple addition to me that would enable better bulk operations and indexing-time aggregations like storing a rank, percentiles, etc.
By the example of the Eden Network Subgraph, that would enable them to save a lot of database reads and writes:
Instead of (simplified ranking logic from them):
let stakers = network.stakers.map<Staker | null>(id => Staker.load(id)).filter(staker => staker != null);
let sortedStakers = stakers((a, b) =>
b.staked.div(WEI).minus(a.staked.div(WEI)).toI32()
);
sortedStakers.forEach((staker, index) => {
staker.rank = BigInt.fromI32(index);
staker.save();
});
They could do something like:
let stakers = Stakers.findMany({ orderBy: { staked: 'desc' } });
let rankedStakers = sortedStakers.map((staker, index) => {
staker.rank = BigInt.fromI32(index);
return staker;
});
Stakers.saveMany(rankedStakers);
Currently, they have ~7000 stakers. That addition would save them 14k-2 database operations.
Current behaviour
In order to update multiple entities in one mapping, subgraph developers are forced to store the ids of all entities that they would like to update in an array on a global singleton entity. That leads to unnecessary big arrays in the database and unnecessary amount of reads and writes.
Affected subgraphs
- Eden Network
- Superfluid
- ...
Inspiration
I personally think the Prisma V2 ORM is pretty well designed: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#findmany
- Ngôn ngữ chính
- Rust
- Star
- 3.2k
- Fork
- 1.1k
- Merge trung bình
- 4 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của graphprotocol/graph-node
-
current: include emits an all-null bucket for dimensionless aggregations, nulling the whole response Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
graphprotocol/graph-node#6719 ·
-
RUSTSEC-2026-0194: Quadratic run time when checking a start tag for duplicate attribute names Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
graphprotocol/graph-node#6673 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
graphprotocol/graph-node#6650 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
graphprotocol/graph-node#6722 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
graphprotocol/graph-node#6721 ·
Tất cả issue của graphprotocol/graph-node
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100