cordiverse / minato

Type Driven Database Framework.
MIT License
27 stars 12 forks source link

minato

Codecov downloads npm GitHub

Type Driven Database Framework.

Features

Driver Supports

Driver Version Notes
Memory npm In-memory driver support
MongoDB npm
MySQL npm MySQL 5.7+, MariaDB 10.5
PostgreSQL npm PostgreSQL 14+
SQLite npm

Basic Usage

import Database from 'minato'
import MySQLDriver from '@minatojs/driver-mysql'

const database = new Database()

await database.connect(MySQLDriver, {
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: '',
  database: 'minato',
})

Data Definition

database.extend('user', {
  id: 'number',
  name: 'string',
  age: 'number',
  money: { type: 'number', initial: 100 },
}, {
  primary: 'id',
  autoInc: true,
})

Simple API

create

const user = await driver.create('user', {
  name: 'John',
  age: 20,
}) // { id: 1, name: 'John', age: 20, money: 100 }

get

remove

set

upsert

Selection API

Using TypeScript

Using Multiple Drivers