Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rahmanfadhil/cotton
SQL Database Toolkit for Deno
https://github.com/rahmanfadhil/cotton
deno sql typescript
Last synced: 3 months ago
JSON representation
SQL Database Toolkit for Deno
- Host: GitHub
- URL: https://github.com/rahmanfadhil/cotton
- Owner: rahmanfadhil
- License: mit
- Created: 2020-05-22T03:55:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-01T14:19:45.000Z (over 2 years ago)
- Last Synced: 2024-06-21T18:10:51.756Z (5 months ago)
- Topics: deno, sql, typescript
- Language: TypeScript
- Homepage: https://rahmanfadhil.github.io/cotton
- Size: 1.28 MB
- Stars: 138
- Watchers: 4
- Forks: 26
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno-cn - @rahmanfadhil/cotton
- awesome-deno - cotton - SQL Database Toolkit for deno (Modules / Database)
README
# Cotton
![ci](https://github.com/rahmanfadhil/cotton/workflows/ci/badge.svg?branch=master) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/rahmanfadhil/cotton)
**SQL Database Toolkit for Deno.**
- Well-tested
- Type-safe
- Supports **MySQL**, **SQLite**, and **PostgreSQL**
- Semantic versioning## Documentation
- [Getting started guide](https://rahmanfadhil.github.io/cotton)
- [Explore the API](https://doc.deno.land/https/deno.land/x/cotton/mod.ts)## Getting Started
Here's an example of a Deno project that uses Cotton.
```ts
import { connect } from "https://deno.land/x/[email protected]/mod.ts";const db = await connect({
type: "sqlite",
database: "db.sqlite3",
});
```To use Cotton in your project, you can import `cotton` package from [deno.land/x](https://deno.land/x) in your file. We highly recommend you to use semantic versioning by explicitly tell Deno which version you want to use in the import URL.
Typically, the first thing you want to do is to create a connection to a database. Here, we're using `connect` and pass our database configuration. You can read more about connection [here](connection.md).
Once our database is connected, do anything with it such as performing an SQL query.
```ts
const users = await db.query("SELECT * FROM users");for (const user of users) {
console.log(user); // { email: '[email protected]', age: 16, ... }
}
```You can learn more about Cotton through these links. Have fun! 😃
- [Creating a connection](docs/guide/connection.md)
- [Query builder](docs/guide/query-builder.md)
- [Object-relational mapper](docs/guide/model.md)
- [Database migrations](docs/guide/migrations.md)