awesome-sql
v0.0.3
Published
A light weight awesome sql sdk with promises and typescript.
Downloads
2
Maintainers
Readme
My Awesome Sql
A light weight awesome sql sdk with promises and typescript.
Getting Started
To tnstall AwesomeSql
in your project.
pnpm install awesome-sql
Examples
Create Connection
Create a connection with your database.
// database.ts
import awesomeSql from "awesome-sql";
export const sql = await awesomeSql.getInstance({
host: "127.0.0.1",
port: 3306,
database: "awesome-sql",
user: "root",
password: "2023",
});
Select
Selecting is the amazing fact of AwesomeSql
.
Select a single data
import { sql } from "./database";
await sql.select({
model: "posts",
columns: ["id", "title", "createdAt"],
where: {
id: 1,
},
});
Join tables
Unbelivealbe things of awesomeSql
with awesome joining.
import { sql } from "./database";
await sql.select({
model: "posts",
columns: ["id", "title", "createdAt"],
where: {
id: 1,
},
joins: [
{
model: "users",
as: "user",
columns: ["name", "email"],
on: { id: "userId" },
},
],
});
Insert
Inserting on awesomeSql
is so easy.
Insert single data
import { sql } from "./database";
await sql.insert({
model: "users",
data: [{ name: "mahi", email: "[email protected]", password: "mahi" }],
});
Insert multiple data
import { sql } from "./database";
await sql.insert({
model: "users",
data: [
{ name: "mahi", email: "[email protected]", password: "mahi" },
{ name: "koishor", email: "[email protected]", password: "koishor" },
],
});
Update
Update a data existing data
import { sql } from "./database";
await sql.update({
model: "users",
data: { name: "name updated" },
where: {
name: "mahi",
},
});
Delete
Delete a data with the easiest way
import { sql } from "./database";
await sql.delete({
model: "users",
where: {
name: "name updated",
},
});
Inspiration
We get the inspiration of this project from Mongoose, Sequlize. There are an awesome ORM. They have a tungs of features to manupulate data.