Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update [PrimaryKeyProp] Syntax for Enhanced Clarity #6

Open
Daniel-Boll opened this issue Jul 10, 2024 · 0 comments
Open

Update [PrimaryKeyProp] Syntax for Enhanced Clarity #6

Daniel-Boll opened this issue Jul 10, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@Daniel-Boll
Copy link
Owner

To improve the readability and clarity of the primary key definitions in our models, we propose updating the [PrimaryKeyProp] syntax. The new syntax will explicitly separate partition keys and clustering keys. This change aims to make the primary key structure more understandable and maintainable.

Current Example:

@Model("users")
class User extends BaseModel {
  @Column({ partitionKey: true })
  id: Uuid;
  
  @Column()
  name: string;
  
  @Column()
  address: string;
  
  [PrimaryKeyProp]?: [["id"], ["name", "address"]];
}

Proposed Change:

Update the [PrimaryKeyProp] syntax to use a more descriptive object structure:

@Model("users")
class User extends BaseModel {
  @Column({ partitionKey: true })
  id: Uuid;
  
  @Column()
  name: string;
  
  @Column()
  address: string;
  
  [PrimaryKeyProp]?: {
    partitionKeys: ["id"];
    clusteringKeys: ["name", "address"];
  };
}

Goal:

  • Improve Readability: Make the primary key definitions clearer by explicitly distinguishing between partition keys and clustering keys.
  • Maintainability: Enhance the maintainability of the code by using a more structured approach.
  • Implementation Feasibility: Validate if this change is feasible within the current framework and, if so, implement it.

Tasks:

  1. Validation:
    • Assess the feasibility of implementing this new syntax within the current system.
  2. Implementation:
    • Update the codebase to support the new [PrimaryKeyProp] syntax.
    • Ensure that all relevant parts of the system correctly interpret and utilize the new structure.
  3. Documentation:
    • Update the documentation to reflect the new syntax.
    • Provide examples and guidelines for using the new primary key prop structure.

This change will provide a more intuitive and clear way to define primary keys, benefiting both new and existing users of the library.

@Daniel-Boll Daniel-Boll added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant