@lambda-group/charydbis
Version:
๐ NodeJS ScyllaDB ORM. ๐งช๐ง
78 lines (50 loc) โข 2.19 kB
Markdown
<div align="center">
<a href="https://github.com/daniel-boll/charydbis">
<img src="assets/logo.png" alt="scylladb" width="340" />
</a>
<h4>๐ JavaScript ORM for ScyllaDB. Pre-release stage. ๐งช๐ง</h4>
</div>
## ๐ฅ Installing ๐ฅ
To install this package, use the following command:
```bash
npm i @lambda-group/charydbis @lambda-group/scylladb
```
## ๐ Getting Started ๐
These instructions will get you a copy of the project up and running ๐ on your local machine for development and testing purposes.
### ๐ Prerequisites ๐
- Docker: We use Docker ๐ณ to run the Scylla database easily without the need for a complex local setup.
- Node.js: Make sure you have Node.js installed on your system to run JavaScript code.
- Scylla Driver: To handle the connections.
### ๐ Quickstart ๐
1. **Start ScyllaDB in Docker:**
Run a ScyllaDB instance using the following Docker command:
```bash
docker run --name scylladb -d --rm -it -p 9042:9042 scylladb/scylla --smp 2
```
This command pulls the Scylla image if it's not already present on your system, and starts a new ๐ container with the Scylla database.
2. **Create a DataSource:**
Here's a simple script that creates a data source:
```typescript
import { DataSource } from "@lambda-group/charydbis";
using scyllaDataSource = await new DataSource({
nodes: ["localhost:9042"],
}).initialize("system_schema");
```
Here we leverage the `using` keyword so in the end of the scope on [Symbol.dispose] we automatically close the connection so you don't have to bother.
3. **Create a model:**
Now we can create a structure that will represent out data.
```typescript
@Model("scylla_tables")
class ScyllaTables {
@Column()
name: string;
}
```
4. **Access the repository:**
You can now get a default repository from the model.
```ts
const scyllaTablesRepository = scyllaDataSource.getRepository(ScyllaTables);
const tables: Array<ScyllaTables> = await scyllaTablesRepository.find();
```
---
You can find more [examples](https://github.com/daniel-boll/charydbis/tree/main/examples) in the examples folder.