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

examples: Split Examples into Defined Concepts #4

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

examples: Split Examples into Defined Concepts #4

Daniel-Boll opened this issue Jul 9, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Daniel-Boll
Copy link
Owner

To enhance the clarity and usability of the library, we should create distinct examples for each core concept. This will allow users to quickly understand and implement specific features. Below is a basic example that should serve as a foundational template:

Basic Example

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

	@Column()
	name: string;

	@Column()
	address: string;

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

async function main() {
	using scyllaDataSource = await new DataSource({
		nodes: ["localhost:9042"],
	}).initialize("examples_basic");

	const userRepository = scyllaDataSource.getRepository(User);

	const user = new User();
	user.id = Uuid.randomV4();
	user.name = "John Doe";
	user.address = "123 Main St.";

	await userRepository.save(user);

	const result = await userRepository.findBy({
		id: user.id,
	});

	console.log(result[0]);
} // DataSource will be discarded here on [Symbol.dispose] because of `using`

Additional Examples

  1. Partition Key:

    • Example demonstrating the use of partition keys with multiple fields.
  2. Clustering Key:

    • Example showing how to implement clustering keys and their impact on data sorting.
  3. Authentication:

    • Example illustrating how to set up and use authentication.
  4. Multiple Nodes:

    • Example detailing configuration and usage of multiple nodes in a cluster.

By breaking down the examples into these smaller, focused parts, users will be able to grasp each concept more effectively and apply them as needed in their own projects.

@Daniel-Boll Daniel-Boll added documentation Improvements or additions to documentation help wanted Extra attention is needed good first issue Good for newcomers labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant