https://github.com/tortitast/dormlite
An sqlite orm for Deno
https://github.com/tortitast/dormlite
deno
Last synced: about 2 months ago
JSON representation
An sqlite orm for Deno
- Host: GitHub
- URL: https://github.com/tortitast/dormlite
- Owner: TortitasT
- Created: 2022-11-23T19:22:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-20T18:03:50.000Z (over 3 years ago)
- Last Synced: 2024-12-30T20:14:59.938Z (over 1 year ago)
- Topics: deno
- Language: TypeScript
- Homepage: https://deno.land/x/dormlite@0.0.1
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deno Orm sqLite
An sqlite orm library on Deno for my personal projects. Depends on [sqlite@v3.7.0](https://deno.land/x/sqlite@v3.7.0).
## Import
```ts
import { Database } from "https://deno.land/x/dormlite/mod.ts";
```
## Usage
Usage is covered on [the tests](./mod.test.ts). You can run them with
```bash
deno test --allow-read --allow-write
```
Quick example:
```ts
import { Database } from "https://deno.land/x/dormlite/mod.ts";
class User extends Model {
static tableName = "users"; // Table name
name: string;
email: string;
constructor(
name: string,
email: string,
) {
super();
this.name = name;
this.email = email;
}
}
await Database.init(
"test", // Database file name
[User]
);
const user = new User("John Doe", "john@doe.es");
await User.create(user);
console.log(await User.all()); // [User { id: 1, name: "John Doe", email: "john@doe.es" }]
Database.db.close();
Deno.removeSync("test.sqlite");
```