loopbackio / loopbackio/loopback-next
[EPIC] Composite primary/foreign keys
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 5.1k
- Fork
- 1.1k
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 27
Mô tả
See https://github.com/strongloop/loopback/issues/2080 for the original discussion in LB 2.x/3.x.
LoopBack should support models using composite keys, where a primary key or a foreign key is composed from multiple properties.
Let's consider the following models as an example:
// A (GitHub) repository is identified by the pair [user, name]
// and has many issues
@model
class Repository {
@property({id: true})
user: string;
@property({id: true}
name: string;
@hasMany(() => Issue)
issues: Issue[];
}
// An issue belongs to a repository
@model
class Issue {
// how to specify @belongsTo relation?
}
Functional areas we need to cover:
- How to define a model with a composite primary key (e.g. Repository above)?
- Connectors must understand composite ids and convert them to a concept the target database understands. SQL is easy because it supports composite primary keys OOTB, NoSQL like MongoDB and Cloudant can be tricky.
- create a new model
- find a model by id
- update (patch/replace) a model by id
- delete a model by id
- (etc.)
- Autoupdate/automigrate need to support composite primary keys too
- How to define composite foreign key in a model belonging to another model (e.g. Issue above)
- Relation repositories must work with composite keys
- How to expose a model with a composite primary key via REST API?
- How to expose a relation using a composite foreign key via REST API?
- Controller templates need to produce code that works with composite primary/foreign keys.
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.
Hướng nghiên cứu
Bắt đầu với cuộc thảo luận được liên kết về LB 2.x/3.x và ví dụ về model Repository/Issue. Phạm vi công việc bao gồm các định nghĩa model, connector, automigrate/autoupdate, các relation repository, việc expose REST và các controller template; công việc được coi là hoàn tất khi đã thống nhất việc hỗ trợ cho từng operation được liệt kê và có một kế hoạch triển khai có thể kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- api, backend, databases
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100