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

decorators: Automatic Primary Key Prop #5

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

decorators: Automatic Primary Key Prop #5

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

Comments

@Daniel-Boll
Copy link
Owner

For the basic scenario of a single partition key, it should be possible to automatically add the PrimaryKeyProp type within the decorator itself. This would simplify the model definition and reduce boilerplate code.

Current Example:

@Model("users")
class User extends BaseModel {
	@Column({ partitionKey: true })
	id: Uuid;

	@Column()
	name: string;

	@Column()
	address: string;

	[PrimaryKeyProp]?: [["id"]];
}

Proposed Change:

Automatically include the PrimaryKeyProp based on the partitionKey annotation:

@Model("users")
class User extends BaseModel {
+	@Column({ partitionKey: true })
	id: Uuid;

	@Column()
	name: string;

	@Column()
	address: string;

-	[PrimaryKeyProp]?: [["id"]];
}

Goal:

The goal is to validate if this approach is feasible and, if so, implement it. By using the partitionKey annotation within the column decorator, we should be able to automatically define the primary key property. This enhancement aims to streamline the model definition process and improve developer experience.

@Daniel-Boll Daniel-Boll added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers 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 good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant