loopbackio / loopbackio/loopback-next

[EPIC] Composite primary/foreign keys

Đang mở
#1,830 22 bình luận 66 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

epic feature major Relations Repository REST
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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.