# gen_sql_sentence

> 学习制作上传npm包，仅支持ES6

Latest version **1.0.1** (published 2023-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install gen_sql_sentence
pnpm add gen_sql_sentence
yarn add gen_sql_sentence
bun add gen_sql_sentence
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-09-19 |
| First published | 2023-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zengyiyan |
| Maintainers | zengyiyan |
| Keywords | learning, sql, es6, ES6 |

## Links

- npm: https://www.npmjs.com/package/gen_sql_sentence
- Repository: https://github.com/zengyiyan/gen-sql-sentence
- Homepage: https://github.com/zengyiyan/gen-sql-sentence#readme
- Issues: https://github.com/zengyiyan/gen-sql-sentence/issues
- npm.io page: https://npm.io/package/gen_sql_sentence

## Recent versions

- 1.0.1 (latest) — 2023-09-19
- 1.0.0 — 2023-09-19

## README

# 标题
## 说明
这是一个简单的sql语句生成包，目前只支持`select`，`insert` `update` `delete`四种基础语句
### 安装与调用
安装  `npm install gen-sql-sentence`  
调用  `import gen_sql from "gen-sql-sentence"`
### 使用示例
#### `select`
~~~javascript
const sql_select = gen_sql({
  operation: "select",
  table: "userinfo",
  values: ["isAdmin", "status"],
  conditions: {
    userid: "1",
    username: "admin",
  },
});
~~~
#### `insert`
~~~javascript
const sql_insert = gen_sql({
  operation: "insert",
  table: "userinfo",
  values: ["admin", "5"],
  conditions: {},
});
~~~
#### `update`
~~~javascript
const sql_update = gen_sql({
  operation: "update",
  table: "userinfo",
  values: {
    userid: "2",
  },
  conditions: {
    userid: "1",
    username: "admin",
  },
});
~~~
#### `delete`
~~~javascript
const sql_delete = gen_sql({
  operation: "delete",
  table: "userinfo",
  values: [],
  conditions: {
    userid: "1",
    username: "admin",
  },
});
~~~
#### 调用结果
~~~javascript
sql_select = "select isAdmin, status from userinfo where userid = 1, username = admin;"
sql_insert = "insert into userinfo values (admin, 5);"
sql_update = "update userinfo set userid = 2 where userid = 1, username = admin;"
sql_delete = "delete from userinfo where userid = 1, username = admin;"
~~~
#### 参数说明
`operation`和`table`参数为必要参数，可以是`string`或`String`类  
`values`和`conditions`是否必要可以参考对应的`sql`语句本身要求  
`values`在`select`语句和`insert`语句中可以是`Array`或者`Object`（若为`Object`，`value`应存放在值的位置），在`update`语句中只能是`Object`  
`conditions`只能是`Object`  
参数若不存在，即默认为`undefined`，`undefined`和`{}`在满足对应的`sql`语句本身要求的前提下属于合规的输入
## 相关仓库
跳转到  [github](https://github.com/zengyiyan/gen-sql-sentence "github仓库地址")  或者  [npm](https://www.npmjs.com/package/gen_sql_sentence "npm仓库地址")

---
_Source: https://npm.io/package/gen_sql_sentence · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
