Type Driven Database Framework.

Related tags

Database cosmotype
Overview

cosmotype

Codecov npm

Type Driven Database Framework.

Features

  • Compatibility. Complete driver-independent. Supports many drivers with a unified API.
  • Powerful. It can do everything that SQL can do, even though you are not using SQL drivers.
  • Well-typed. Cosmotype is written with TypeScript, and it provides top-level typing support.
  • Extensible. Simultaneous accesss to different databases based on your needs.
  • Modern. Perform all the operations with a JavaScript API or even in the brower with low code.

Driver Supports

Driver Version Notes
MySQL npm MySQL 5.7, MySQL 8.0, MariaDB 10.5
MongoDB npm
SQLite npm
LevelDB npm
Memory npm In-memory driver support

Basic Usage

import { Database } from 'cosmotype'

const database = new Database()

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

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

Comments
  • 所有测试全都是Memory Database

    所有测试全都是Memory Database

    是有什么原因吗

    https://github.com/shigma/minato/blob/f16d19e78e4d848ca6d62eff46424e5359fc60be/packages/mongo/tests/index.spec.ts#L4 https://github.com/shigma/minato/blob/f16d19e78e4d848ca6d62eff46424e5359fc60be/packages/mysql/tests/index.spec.ts#L4 https://github.com/shigma/minato/blob/f16d19e78e4d848ca6d62eff46424e5359fc60be/packages/level/tests/index.spec.ts#L5 https://github.com/shigma/minato/blob/f16d19e78e4d848ca6d62eff46424e5359fc60be/packages/sqlite/tests/index.spec.ts#L5

    opened by simon300000 4
  • feat: add an API to drop specific table

    feat: add an API to drop specific table

    descrpition of this pull request

    Add an API to drop specific table.

    the issue of this pull request aim to solve

    This pull request aims to solve the problem of not being able to delete specific tables. Currently, minato only has an API for deleting all tables. this pull request adds the ability to delete specific tables.

    opened by Seidko 2
  • mysql driver 在建表之前查询

    mysql driver 在建表之前查询

    opened by Anillc 2
  • Bug: MySQL Driver在处理list类型时出错

    Bug: MySQL Driver在处理list类型时出错

    Describe the bug

    我是在使用forward插件时发现这个问题的。当我使用forward.add添加转发频道后并没有正常转发,而使用forward.list查看了一下后发现结果严重不符合预期。后来我自己写了一个测试插件后发现可能是database-mysql对list的处理不正常(详见下图)。 具体来说,就是会在list的项中出现"""、"","[]"等不应该出现的字符。

    Steps to reproduce

    1. 初始化模板项目
    2. 配置好database-mysql
    3. 使用任意一个需要在database中存储list的插件
    4. 出现错误

    Expected behavior

    应该和其他database插件一样正常存储list类型的数据。

    Screenshots

    }FT)0GP MYTKPZVI8Q8WZ6](https://user-images.githubusercontent.com/61967203/205481155-c3679533-37d0-4d5a-88b3-13d8f6703795.png)
![9NJ0ALP69UET%SB)5O{(~E ZO1K4$%V0{S@VA$M_KN)FZ0 XNF}){QOB0{UG(T6QMY8JWB

    Versions

    • OS: Windows 11 & Ubuntu 20.04 LTS
    • Platform: 与平台无关
    • Node version: 18.4.0(Win)/18.6.0(Ubuntu)
    • Koishi version: 4.10.4
    opened by ConstasJ 0
  • Feature request: sqlite REGEXP

    Feature request: sqlite REGEXP

    dialogue 读取带图片问答时报错,报错内容为 Error: no such function: REGEXP

    复现流程:

    1. 安装 koishi desktop 0.9.1
    2. 安装配置 assets-local dialogue onebot 插件
    3. onebot 群聊中添加对话 foo,回答为一张图片
    4. 群聊中输入 foo,没有回复
    5. 查看 log

    相关日志:

    2022-12-30 17:19:13 [W] sqlite > SELECT * FROM `dialogue` bcrghqyv WHERE (`flag` & 2 = 2 AND 'foo' REGEXP `original` OR `flag` & 2 = 0 AND `question` = 'foo')
    2022-12-30 17:19:13 [W] session foo
                            Error: no such function: REGEXP
                                at f.handleError (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\sql.js\dist\sql-wasm.js:91:290)
                                at f.prepare (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\sql.js\dist\sql-wasm.js:90:46)
                                at SQLiteDriver.#exec (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\driver-sqlite\lib\index.js:307:26)
                                at SQLiteDriver.#all (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\driver-sqlite\lib\index.js:319:48)
                                at SQLiteDriver.get (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\driver-sqlite\lib\index.js:241:54)
                                at Selection.execute (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\core\lib\index.cjs:349:34)
                                at Selection.execute (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\core\lib\index.cjs:414:20)
                                at DatabaseService.get (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\@minatojs\core\lib\index.cjs:496:22)
                                at processTicksAndRejections (node:internal/process/task_queues:96:5)
                                at async DialogueService.get (C:\Users\42\AppData\Roaming\Koishi\Desktop\data\instances\default\node_modules\koishi-plugin-dialogue\lib\index.js:126:25)
    
    opened by MirrorCY 0
Owner
null
🔥 Dreamy-db - A Powerful database for storing, accessing, and managing multiple database.

Dreamy-db About Dreamy-db - A Powerful database for storing, accessing, and managing multiple databases. A powerful node.js module that allows you to

Dreamy Developer 24 Dec 22, 2022
DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB database, such as: connecting to the database, executing scripts, calling functions, uploading variables, etc.

DolphinDB JavaScript API English | 中文 Overview DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB

DolphinDB 6 Dec 12, 2022
just a graphql example created by typescript + fastify + mikro-orm(postgresql) + mercurius(graphql adaptor) + type-graphql

fastify-mikro-orm-mercurius-graphql-example A MikroORM boilerplate for GraphQL made with Fastify, Mercurius, Typescript using TypeGraphQL ?? Packages

Vigen 10 Aug 28, 2022
graphql-codegen plugin to generate type-safe, easy-to use hooks for Flutter

graphql-codegen-flutter-artemis-hooks This is graphql-codegen plugin to generate type-safe, easy-to use Flutter artemis hooks. For further detail, see

seya 18 Jan 2, 2023
An in-depth implementation of Clean Architecture using NestJS and type-script

Clean Architecture With NestJS Description It's been a while since my last article on how to implement clean architecture on Node.js applications, git

null 297 Dec 28, 2022
🔄 A realtime Database for JavaScript Applications

RxDB A realtime Database for JavaScript Applications RxDB (short for Reactive Database) is a NoSQL-database for JavaScript Applications like Websites,

Daniel Meyer 18.6k Dec 31, 2022
⚡️ lowdb is a small local JSON database powered by Lodash (supports Node, Electron and the browser)

Lowdb Small JSON database for Node, Electron and the browser. Powered by Lodash. ⚡ db.get('posts') .push({ id: 1, title: 'lowdb is awesome'}) .wri

null 18.9k Dec 30, 2022
:koala: - PouchDB is a pocket-sized database.

PouchDB – The Database that Syncs! PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the br

PouchDB 15.4k Dec 30, 2022
Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!

PostGraphile Instant lightning-fast GraphQL API backed primarily by your PostgreSQL database. Highly customisable and extensible thanks to incredibly

Graphile 11.7k Jan 4, 2023
🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️

A reactive database framework Build powerful React and React Native apps that scale from hundreds to tens of thousands of records and remain fast ⚡️ W

Nozbe 8.8k Jan 5, 2023
Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.

Lovefield Lovefield is a relational database written in pure JavaScript. It provides SQL-like syntax and works cross-browser (currently supporting Chr

Google 6.8k Jan 3, 2023
AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.

Please use version 1.x as prior versions has a security flaw if you use user generated data to concat your SQL strings instead of providing them as a

Andrey Gershun 6.1k Jan 9, 2023
Realm is a mobile database: an alternative to SQLite & key-value stores

Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript versions of Realm. Currently we s

Realm 5.1k Jan 3, 2023
:rocket: One command to generate REST APIs for any MySql Database.

Xmysql : One command to generate REST APIs for any MySql database Why this ? Generating REST APIs for a MySql database which does not follow conventio

null 129 Dec 30, 2022
Realtime database backend based on Operational Transformation (OT)

This README is for [email protected]. For [email protected], see the 1.x-beta branch. To upgrade, see the upgrade guide. ShareDB ShareDB is a realtime databa

ShareJS 5.5k Dec 29, 2022
A transparent, in-memory, streaming write-on-update JavaScript database for Small Web applications that persists to a JavaScript transaction log.

JavaScript Database (JSDB) A zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to

Small Technology Foundation 237 Nov 13, 2022
The JavaScript Database, for Node.js, nw.js, electron and the browser

The JavaScript Database Embedded persistent or in memory database for Node.js, nw.js, Electron and browsers, 100% JavaScript, no binary dependency. AP

Louis Chatriot 13.2k Jan 2, 2023
Bluzelle is a smart, in-memory data store. It can be used as a cache or as a database.

SwarmDB ABOUT SWARMDB Bluzelle brings together the sharing economy and token economy. Bluzelle enables people to rent out their computer storage space

Bluzelle 225 Dec 31, 2022
The ultimate solution for populating your MongoDB database.

Mongo Seeding The ultimate solution for populating your MongoDB database ?? Define MongoDB documents in JSON, JavaScript or even TypeScript files. Use

Paweł Kosiec 494 Dec 29, 2022