Skip to content

Commit d39aab9

Browse files
committed
Merge branch 'main' of https://github.com/akrouk/PromiseSQL
2 parents 5381f78 + 9b22e88 commit d39aab9

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,50 @@
1-
# PromiseSQL
1+
# :hatching_chick: PromiseSQL
2+
A [node-sqlite3](https://www.npmjs.com/package/sqlite3) wrapper for running simple, promise-based database queries in Node.js. It works best in smaller projects with a lot of asynchronous development, e.g., a Discord bot that implements slash commands.
3+
4+
```javascript
5+
const db = require('promisesql');
6+
db.open('./database.db');
7+
8+
(async () => {
9+
const data = await db.select({
10+
all: true,
11+
from: 'lorem',
12+
where: [ db.expression.eq('ipsum', 'dolor') ]
13+
});
14+
15+
data.forEach(datum => console.log(datum.dolor));
16+
})();
17+
18+
db.close();
19+
```
20+
21+
***This module is still a work in progress.***
22+
23+
By design, it was created as an SQL backend for interaction-based Discord bots built in [discord.js v13](https://discord.js.org/#/docs/discord.js/v13/general/welcome). It is intended to create more user-friendly, asynchronous query functions, which take in an "options" object as arguments, a practice inspired by discord.js.
24+
25+
While it can run any query asychronously, it currently only supports the following built-in query and expression functions:
26+
27+
## Queries
28+
29+
### Insert
30+
`insert({ table: string, columns?: string[], values: string[])`
31+
```javascript
32+
const id = '123456789';
33+
const username = 'user99';
34+
35+
await db.insert({
36+
table: 'users',
37+
columns: [ 'id', 'username' ],
38+
values: [ id, username ]
39+
});
40+
```
41+
42+
### Select
43+
### Update
44+
### Delete
45+
## Expressions
46+
- Boolean
47+
- Aggregate
48+
49+
## Future plans
50+
Presently, there are no plans to add functionality such as creating tables, attaching databases, etc. For now, I handle operations like that with [DB Browser](https://sqlitebrowser.org/), which is a great tool for managing tables and data in small SQLite3 databases.

0 commit comments

Comments
 (0)