Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlinecode committed Mar 22, 2023
0 parents commit 750be13
Show file tree
Hide file tree
Showing 11 changed files with 1,094 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build
on:
workflow_dispatch:
push:
branches:
- "master"
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: "18.13.0"
registry-url: "https://registry.npmjs.org"
- run: npm i
- run: npm run build
- name: Commit files
run: |
git add .
git commit -m "Build"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
BunORM*.tgz
yarn-error.log
37 changes: 37 additions & 0 deletions Logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<p align="center">
<a href="https://github.com/deadlinecode/BunORM"><img src="Logo.svg" alt="Logo" height=70></a>
<br />
</p>
<hr />
<br />

## What is BunORM 🤔

BunORM is a ORM implementation for bun:sqlite that makes it easy to manage your bun:sqlite database by not only providing a simple to use interface, but also really good typescript support
<br />
(This package is still in an very early state so dont expect to much lol)
<br />
<br />

## Features 😯

1. ⚡ BLAZINGLY FAST
2. 😮 Tiny no-dependencies package
2. 🔤 Bestest autocompletion due to really good typescript types
3. 💻 Easy to use interface inspired by <a href="https://typeorm.io">TypeORM</a>
4. Supports following cool features out of the box:
- Custom data types like "JSON" with full type support (so you dont have to cast 😉)
- Middleware support (get/set)
- Custom functions that will be added to the row objects
- Relations between tables (also with type support)
- Automatic Id, createdAt and updatedAt properties
<br />
<br />

## Installation

Stable release
```bash
bun install bunorm
```

Dev release
```bash
bun install https://github.com/deadlinecode/BunORM
```
<br />

## Usage

Just import the package
```ts
import { BunORM } from "bunorm";
```

and define your table like this
```ts
const db = new BunORM("db.sqlite", {
tables: {
roles: {
columns: {
name: {
type: "TEXT",
},
},
},
users: {
columns: {
username: {
type: "TEXT",
},
password: {
type: "TEXT",
},
userData: {
type: "JSON",
},
},
},
},
});
```
Then use it ^~^
```ts
const users = db.tables.users.find();
```
Wait thats not all!!!
<br />
BunORM can do so much more for you 😎
<br />
Just take a look at the <a href="https://github.com/deadlinecode/BunORM/tree/master/src/example">example folder</a>
<br />
<br />

## I wanna tweak it for my own use case ÒvÓ

Sure thing! You can tinker with the package like this:
1. Clone the repo
```bash
git clone https://github.com/deadlinecode/BunORM .
```
2. Change stuff you wanna change
3. Build the package
```bash
npm build
```
4. Install it in another nodejs project from wherever you saved it on your disk
```bash
# inside your other project
npm install /path/to/the/repo/named/BunORM
```
or alternatively run the example
```bash
# inside the package folder
bun run src/example/example.ts
```
<br/>
<br/>

## Found a bug or want to contribute because you're a cool person?

If you found an issue or would like to submit an improvement, please [open an issue here](https://github.com/deadlinecode/BunORM/issues/new/choose).

If you actually have some spare time and want to contribute, feel free to open a PR and please don't forget to (create and) link the corresponding issue. <br/>
It's important so we can keep track of all the issues and feature requests that got resolved by PRs.
<br/>
<br/>
Please!
<br/>
Please! Please! Please! Please! Please use the dev branch when making changes and PRs. I won't accept any changes to the master branch.
<br/>
<br/>

## Known issues/feature requests (WIP)
- [ ] Cleaning up the messy shit i call "code"
- [ ] Adding support for multiple relation types (one-to-many, one-to-one, etc.)
- [ ] Support relations both ways if one is set
- [ ] `db.tables.[table].save` should return the saved entity
- [ ] Bulk actions for everything
<br/>
<br/>

## You need help or want to exchange about things

Well bad for you.<br/>
Jk. <br/>
I currently don't have a discord but you can find me on the [bun discord server](https://discord.gg/SPjMSDfQ) or just [dm me on discord](https://discord.com/users/330361029366382594)

See ya over there and thanks for using my package ^^ <3
50 changes: 50 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "bunorm",
"version": "0.0.1",
"description": "Synchronous ORM lib for Bun:sqlite - easier db handling",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc",
"prepare": "npm run build"
},
"keywords": [
"orm",
"typescript",
"typescript-orm",
"sqlite",
"bun:sqlite",
"bun",
"bun.js",
"bun.sh"
],
"tags": [
"orm",
"typescript",
"typescript-orm",
"sqlite",
"bun:sqlite",
"bun",
"bun.js",
"bun.sh"
],
"author": "deadlinecode",
"repository": {
"type": "git",
"url": "https://github.com/deadlinecode/BunORM.git"
},
"bugs": {
"url": "https://github.com/deadlinecode/BunORM/issues"
},
"license": "ISC",
"files": [
"lib/**/*"
],
"devDependencies": {
"bun-types": "^0.5.7",
"typescript": "^5.0.2"
}
}
Loading

0 comments on commit 750be13

Please sign in to comment.