An open API service indexing awesome lists of open source software.

https://github.com/9ssi7/query

A fast, synchronized and dynamic query builder package.
https://github.com/9ssi7/query

chain-of-responsibility query query-builder sql typescript

Last synced: about 2 months ago
JSON representation

A fast, synchronized and dynamic query builder package.

Awesome Lists containing this project

README

        



@ssibrahimbas/query



A fast, synchronized and dynamic query builder package.

### What is?

In short, the query builder. You can write complex and parameterized queries fast, plain and dynamically using the Query class, which uses the `chain of responsibility pattern`!

### Motivation

Generally, adding parameters to queries and parsing objects increases the distance of us as software developers to sql. This package was influenced by mongoose's Query class, aiming to make it usable in SQL databases, and that's what it ultimately does.

Run it on the drive you want! Sequelize can work with postgresql or any driver. All it needs is a driver that accepts sql code!

Looking forward to your pull requests and issues to make this package better.

Finally, all functions are gesture tested.

### Installation

To include this package in your project, run the following command:

```
npm install @ssibrahimbas/query
```

> or with yarn
>
> ```
> yarn add @ssibrahimbas/query
> ```

And try this:

```typescript
import { Query } from "@ssibrahimbas/query"

console.log(Query.table("users").getAll())

// SELECT * FROM users
```

### Contributing

If you want to contribute to the project or play with the codes on your local machine, follow the steps below:

#### install dependencies:

```
npm install
```

> or with yarn
>
> ```
> yarn
> ```

#### run tests

```
npm run test
```

> or with yarn
>
> ```
> yarn test
> ```

### Documentation

|Interface|
|---------|
|**[`ISsiQuery`](#issiquery)**|

| Functions |
|--------------------------|
|**[`table(...)`](#table)**|
|**[`select(...)`](#select)**|
|**[`groupConcat(...)`](#groupconcat)**|
|**[`least(...)`](#least)**|
|**[`max(...)`](#max)**|
|**[`min(...)`](#min)**|
|**[`sum(...)`](#sum)**|
|**[`count(...)`](#count)**|
|**[`avg(...)`](#avg)**|
|**[`innerJoin(...)`](#innerjoin)**|
|**[`leftJoin(...)`](#leftjoin)**|
|**[`rightJoin(...)`](#rightjoin)**|
|**[`fullOuterJoin(...)`](#fullouterjoin)**|
|**[`leftOuterJoin(...)`](#leftouterjoin)**|
|**[`rightOuterJoin(...)`](#rightOuterjoin)**|
|**[`where(...)`](#where)**|
|**[`orWhere(...)`](#orwhere)**|
|**[`notWhere(...)`](#notwhere)**|
|**[`orNotWhere(...)`](#ornotwhere)**|
|**[`whereNull(...)`](#wherenull)**|
|**[`whereNotNull(...)`](#wherenotnull)**|
|**[`grouped(...)`](#grouped)**|
|**[`in(...)`](#in)**|
|**[`notIn(...)`](#notin)**|
|**[`orIn(...)`](#orin)**|
|**[`orNotIn(...)`](#ornotin)**|
|**[`findInSet(...)`](#findinset)**|
|**[`notFindInSet(...)`](#notfindinset)**|
|**[`orFindInSet(...)`](#orfindinset)**|
|**[`orNotFindInSet(...)`](#ornotfindinset)**|
|**[`between(...)`](#between)**|
|**[`notBetween(...)`](#notbetween)**|
|**[`orBetween(...)`](#orbetween)**|
|**[`orNotBetween(...)`](#ornotbetween)**|
|**[`like(...)`](#like)**|
|**[`orLike(...)`](#orlike)**|
|**[`notLike(...)`](#notlike)**|
|**[`orNotLike(...)`](#ornotlike)**|
|**[`limit(...)`](#limit)**|
|**[`pagination(...)`](#pagination)**|
|**[`orderBy(...)`](#orderby)**|
|**[`groupBy(...)`](#groupby)**|
|**[`having(...)`](#having)**|
|**[`query(...)`](#query)**|
|**[`get()`](#get)**|
|**[`getAll()`](#getall)**|
|**[`insert(...)`](#insert)**|
|**[`update(...)`](#update)**|
|**[`delete()`](#delete)**|
|**[`analyze()`](#analyze)**|
|**[`check()`](#check)**|
|**[`checksum()`](#checksum)**|
|**[`optimize()`](#optimize)**|
|**[`repair()`](#repair)**|
|**[`reset()`](#reset)**|

### ISsiQuery

Abstract of the Query class. If you wish, you can use as follows:

```typescript
import { ISsiQueue, SsiQuery } from "@ssibrahimbas/query"

const Query : ISsiQuery = new SsiQuery();
```

Although this doable, it is memory redundant as the `new` key is constantly used. The Queue class has been developed to reset itself after each query. So you can use it with peace of mind as follows:

```typescript
import { Query } from "@ssibrahimbas/query"
```

### Functions


### table

It is used to declare a table in SQL.

Abstract:

```typescript
table(table: string | Array) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").getAll();

// SELECT * FROM users
```

Using arrays:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table(["users", "products"]).analyze();

// ANALYZE TABLE users, products
```


### select

Select the fields to use for the query

Abstract:

```typescript
select(fields: Record | Array> | string | Array) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").select("id").getAll();

// SELECT id FROM users
```

Using arrays:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").select(["id As userId", "name As userName"]).analyze();

// SELECT id As userId, name As userName FROM users
```

Using Records:

```typescript
import { Query } from "@ssibrahimbas/query"

const data = { Id: "userId", FirstName: "firstName" };
const query : string = Query.table("users").select(data).getAll();

// SELECT Id AS userId, FirstName AS firstName FROM users
```

Using Records With Arrays:

```typescript
import { Query } from "@ssibrahimbas/query"

const data: Array> = [
{ Id: "userId" },
{ FirstName: "firstName" },
];
const query : string = Query.table("users").select(data).getAll();

// SELECT Id AS userId, FirstName AS firstName FROM users
```


### least

Abstract:

```typescript
least(fields: Array, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").least(["point1", "point2", "point3"], "minPoint").getAll();

// "SELECT LEAST(point1, point2, point3) AS minPoint FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").least(["point1", "point2", "point3"]).getAll();

// "SELECT LEAST(point1, point2, point3) FROM users"
```


### groupConcat

Abstract:

```typescript
groupConcat(fields: string, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").groupConcat("UserId", "users").getAll();

// "SELECT GROUP_CONCAT(UserId) AS users FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").groupConcat("UserId").getAll();

// "SELECT GROUP_CONCAT(UserId) FROM users"
```


### max

Abstract:

```typescript
max(fields: string, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").max("id", "count").getAll();

// "SELECT MAX(id) AS count FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").max("id").getAll();

// "SELECT MAX(id) FROM users"
```


### min

Abstract:

```typescript
min(fields: string, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").min("id", "count").getAll();

// "SELECT MIN(id) AS count FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").min("id").getAll();

// "SELECT MIN(id) FROM users"
```


### sum

Abstract:

```typescript
sum(fields: string, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").sum("id", "count").getAll();

// "SELECT SUM(id) AS count FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").sum("id").getAll();

// "SELECT SUM(id) FROM users"
```


### count

Abstract:

```typescript
count(fields: string, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").count("id", "count").getAll();

// "SELECT COUNT(id) AS count FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").count("id").getAll();

// "SELECT COUNT(id) FROM users"
```


### avg

Abstract:

```typescript
avg(fields: string, name?: string | null) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").avg("id", "avg").getAll();

// "SELECT AVG(id) AS avg FROM users"
```

Single Parameter:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").avg("id").getAll();

// "SELECT AVG(id) FROM users"
```


### innerJoin

Abstract:

```typescript
innerJoin(table: string, field1: string, operator?: string, field2?: string) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("user_posts")
.select([
"user_posts.id as postId",
"user_posts.title as postTitle",
"users_username as username",
])
.innerJoin("users", "user_posts.userId", "users.id")
.getAll();

// "SELECT user_posts.id as postId, user_posts.title as postTitle, users_username as username FROM user_posts INNER JOIN users ON user_posts.userId = users.id"
```


### leftJoin

Abstract:

```typescript
leftJoin(table: string, field1: string, operator?: string, field2?: string) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.select(["users.id As userId", "user_posts.title As postTitle"])
.leftJoin("user_posts", "users.id", "user_posts.userId")
.getAll();

// "SELECT users.id As userId, user_posts.title As postTitle FROM users LEFT JOIN user_posts ON users.id = user_posts.userId"
```


### rightJoin

Abstract:

```typescript
rightJoin(table: string, field1: string, operator?: string, field2?: string) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("user_posts")
.select(["users.id As userId", "user_posts.title As postTitle"])
.rightJoin("users", "user_posts.userId", "users.id")
.getAll();

// "SELECT users.id As userId, user_posts.title As postTitle FROM user_posts RIGHT JOIN users ON user_posts.userId = users.id"
```


### fullOuterJoin

Abstract:

```typescript
fullOuterJoin(table: string, field1: string, operator?: string, field2?: string) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.select(["users.id As userId", "user_posts.title As postTitle"])
.fullOuterJoin("user_posts", "users.id", "user_posts.userId")
.getAll();

// "SELECT users.id As userId, user_posts.title As postTitle FROM users FULL OUTER JOIN user_posts ON users.id = user_posts.userId"
```


### leftOuterJoin

Abstract:

```typescript
leftOuterJoin(table: string, field1: string, operator?: string, field2?: string) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.select(["users.id As userId", "user_posts.title As postTitle"])
.leftOuterJoin("user_posts", "users.id", "user_posts.userId")
.getAll();

// "SELECT users.id As userId, user_posts.title As postTitle FROM users LEFT OUTER JOIN user_posts ON users.id = user_posts.userId"
```


### rightOuterJoin

Abstract:

```typescript
rightOuterJoin(table: string, field1: string, operator?: string, field2?: string) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("user_posts")
.select(["users.id As userId", "user_posts.title As postTitle"])
.rightOuterJoin("users", "user_posts.userId", "users.id")
.getAll();

// "SELECT users.id As userId, user_posts.title As postTitle FROM user_posts RIGHT OUTER JOIN users ON user_posts.userId = users.id"
```


### where

Abstract:

```typescript
where(
where: string | Array,
operator?: string | Array | boolean | null,
val?: string | null | number,
type?: string,
andOr?: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.where("id", "=", "1")
.getAll();

// "SELECT * FROM users WHERE id = '1'"
```


### orWhere

Abstract:

```typescript
orWhere(
where: string | Array,
operator?: string | Array | boolean | null,
val?: string | null | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.where("age", "20")
.orWhere("age", ">", "25")
.getAll();

// "SELECT * FROM users WHERE age = '20' OR age > '25'"
```


### notWhere

Abstract:

```typescript
notWhere(
where: string | Array,
operator?: string | Array | boolean | null,
val?: string | null | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.where("age", "20")
.notWhere("age", ">", "25")
.getAll();

// "SELECT * FROM users WHERE age = '20' AND NOT age > '25'"
```


### orNotWhere

Abstract:

```typescript
orNotWhere(
where: string | Array,
operator?: string | Array | boolean | null,
val?: string | null | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.where("age", "20")
.orNotWhere("age", ">", "25")
.getAll();

// "SELECT * FROM users WHERE age = '20' OR NOT age > '25'"
```


### whereNull

Abstract:

```typescript
whereNull(
where: string,
not?: boolean
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").whereNull("email").getAll();

// "SELECT * FROM users WHERE email IS NULL"
```


### whereNotNull

Abstract:

```typescript
whereNotNull(
where: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users").whereNotNull("email").getAll();

// "SELECT * FROM users WHERE email IS NOT NULL"
```


### grouped

Abstract:

```typescript
grouped(
callback: (q: ISsiQuery) => any
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.grouped((q) => {
q.where("country", "TURKEY").orWhere("country", "ENGLAND");
})
.getAll();

// "SELECT * FROM users WHERE (country = 'TURKEY' OR country = 'ENGLAND')"
```


### in

Abstract:

```typescript
in(
field: string,
keys: Array,
type?: string,
andOr?: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("users")
.in("state", [1, 2, 3, 4])
.getAll();

// "SELECT * FROM users WHERE state IN ('1', '2', '3', '4')"
```


### notIn

Abstract:

```typescript
notIn(
field: string,
keys: Array
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.notIn("id", [1, 2, 3])
.getAll();

// "SELECT * FROM test WHERE active = '1' AND id NOT IN ('1', '2', '3')"
```


### orIn

Abstract:

```typescript
orIn(
field: string,
keys: Array
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orIn("id", [1, 2, 3])
.getAll();

// "SELECT * FROM test WHERE active = '1' OR id IN ('1', '2', '3')"
```


### orNotIn

Abstract:

```typescript
orNotIn(
field: string,
keys: Array
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orNotIn("id", [1, 2, 3])
.getAll();

// "SELECT * FROM test WHERE active = '1' OR id NOT IN ('1', '2', '3')"
```


### findInSet

Abstract:

```typescript
findInSet(
field: string,
key: string | number,
type?: string,
andOr?: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.findInSet("selected_tests", 1)
.getAll();

// "SELECT * FROM test WHERE active = '1' AND FIND_IN_SET (1, selected_tests)"
```


### notFindInSet

Abstract:

```typescript
notFindInSet(
field: string,
key: string | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.notFindInSet("selected_tests", 1)
.getAll();

// "SELECT * FROM test WHERE active = '1' AND NOT FIND_IN_SET (1, selected_tests)"
```


### orFindInSet

Abstract:

```typescript
orFindInSet(
field: string,
key: string | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orFindInSet("selected_tests", 1)
.getAll();

// "SELECT * FROM test WHERE active = '1' OR FIND_IN_SET (1, selected_tests)"
```


### orNotFindInSet

Abstract:

```typescript
orNotFindInSet(
field: string,
key: string | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orNotFindInSet("selected_tests", 1)
.getAll();

// "SELECT * FROM test WHERE active = '1' OR NOT FIND_IN_SET (1, selected_tests)"
```


### between

Abstract:

```typescript
between(
field: string,
value1: string | number,
value2: string | number,
type?: string,
andOr?: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.between("age", 12, 35)
.getAll();

// "SELECT * FROM test WHERE active = '1' AND (age BETWEEN '12' AND '35')"
```


### notBetween

Abstract:

```typescript
notBetween(
field: string,
value1: string | number,
value2: string | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.notBetween("age", 12, 35)
.getAll();

// "SELECT * FROM test WHERE active = '1' AND (age NOT BETWEEN '12' AND '35')"
```


### orBetween

Abstract:

```typescript
orBetween(
field: string,
value1: string | number,
value2: string | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orBetween("age", 12, 35)
.getAll();

// "SELECT * FROM test WHERE active = '1' OR (age BETWEEN '12' AND '35')"
```


### orNotBetween

Abstract:

```typescript
orNotBetween(
field: string,
value1: string | number,
value2: string | number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orNotBetween("age", 12, 35)
.getAll();

// "SELECT * FROM test WHERE active = '1' OR (age NOT BETWEEN '12' AND '35')"
```


### like

Abstract:

```typescript
like(
field: string,
data: string,
type?: string,
andOr?: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.like("title", "%nodeJS%")
.getAll();

// "SELECT * FROM test WHERE active = '1' AND title LIKE '%nodeJS%'"
```


### orLike

Abstract:

```typescript
orLike(
field: string,
data: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orLike("title", "%nodeJS%")
.getAll();

// "SELECT * FROM test WHERE active = '1' OR title LIKE '%nodeJS%'"
```


### notLike

Abstract:

```typescript
notLike(
field: string,
data: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.notLike("title", "%nodeJS%")
.getAll();

// "SELECT * FROM test WHERE active = '1' AND title NOT LIKE '%nodeJS%'"
```


### orNotLike

Abstract:

```typescript
orNotLike(
field: string,
data: string
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orNotLike("title", "%nodeJS%")
.getAll();

// "SELECT * FROM test WHERE active = '1' OR title NOT LIKE '%nodeJS%'"
```


### limit

Abstract:

```typescript
limit(
limit: number,
limitEnd?: number | null
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test").where("active", "1").limit(20).getAll();

// "SELECT * FROM test WHERE active = '1' LIMIT 20"
```


### offset

Abstract:

```typescript
offset(
offset: number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.limit(20)
.offset(200)
.getAll();

// "SELECT * FROM test WHERE active = '1' LIMIT 20 OFFSET 200"
```


### pagination

Abstract:

```typescript
pagination(
perPage: number,
page: number
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.pagination(20, 1)
.getAll();

// "SELECT * FROM test WHERE active = '1' LIMIT 20 OFFSET 20"
```


### orderBy

Abstract:

```typescript
orderBy(
orderBy: string,
orderDir?: string | null
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.orderBy("date", "desc")
.getAll();

// "SELECT * FROM test WHERE active = '1' ORDER BY date DESC"
```


### groupBy

Abstract:

```typescript
groupBy(
groupBy: string | Array
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test").where("active", "1").groupBy("id").getAll();

// "SELECT * FROM test WHERE active = '1' GROUP BY id"
```


### having

Abstract:

```typescript
having(
field: string,
operator?: string | Array | null,
val?: string | null
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query : string = Query.table("test")
.where("active", "1")
.groupBy("place")
.having("AVG(salary)", ">=", "3000")
.getAll();

// "SELECT * FROM test WHERE active = '1' GROUP BY place HAVING AVG(salary) >= '3000'"
```


### query

Abstract:

```typescript
query(
query: string,
values?: Array | null
) : ISsiQuery;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const _query = "SELECT * FROM users WHERE userId = ?";
const query = Query.query(_query, ["1"]).getQuery();

// "SELECT * FROM users WHERE userId = '1'"
```


### get

Builds the select query with a limit of 1

Abstract:

```typescript
get() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("users").select("id, firstName").get();

// "SELECT id, firstName FROM users LIMIT 1"
```


### getAll

Builds the select query

Abstract:

```typescript
getAll() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("users").select("id, firstName").getAll();

// "SELECT id, firstName FROM users"
```


### insert

Builds the insert query

Abstract:

```typescript
insert(data: object) : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const data = {
id: "3",
firstName: "John",
};
const query = Query.table("test").insert(data);

// "INSERT INTO test (id, firstName) VALUES ('3', 'John')"
```


### update

Builds the update query

Abstract:

```typescript
update(data: object) : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const data = {
firstName: "John",
age: 22,
};
const query = Query.table("test").where("id", "3").update(data);

// "UPDATE test SET firstName='John', age='22' WHERE id = '3'"
```


### delete

Builds the delete query

Abstract:

```typescript
delete() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("test").where("id", "54").delete();

// "DELETE FROM test WHERE id = '54'"
```


### analyze

Builds the analyze query

Abstract:

```typescript
analyze() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("test").analyze();

// "ANALYZE TABLE test"
```


### check

Builds the check query

Abstract:

```typescript
check() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("test").check();

// "CHECK TABLE test"
```


### checksum

Builds the checksum query

Abstract:

```typescript
checksum() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("test").checksum();

// "CHECKSUM TABLE test"
```


### optimize

Builds the optimize query

Abstract:

```typescript
optimize() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table("test").optimize();

// "OPTIMIZE TABLE test"
```


### repair

Builds the repair query

Abstract:

```typescript
repair() : string;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

const query = Query.table(["test", "test_2"]).repair();

// "REPAIR TABLE test, test_2"
```


### reset

It clears all the values of the query in the class, it is not recommended to use it externally.

Abstract:

```typescript
reset() : void;
```

Example:

```typescript
import { Query } from "@ssibrahimbas/query"

Query.reset();
```