readme.md updated
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
jusax23 2023-02-15 14:46:58 +01:00
parent 580988e2c0
commit 6901eb91b9
2 changed files with 26 additions and 5 deletions

View file

@ -11,7 +11,7 @@ Features:
- [x] remove Query
- [x] create Schema
- [x] remove unused Schema
- [ ] joins
- [x] joins
- [ ] change Schema
- [ ] Key-Value Store Shortcut
- [ ] Views
@ -93,7 +93,7 @@ See: [Modifiers](#modifier), [Aggregations](#aggregations)
#### Select:
```javascript
import {select} from "dblang"
import { select } from "dblang"
let res = await select([Table2.AttrName2], Table1)
.where(eq(Table2.AttrName2, 5)) //optional
@ -101,12 +101,31 @@ let res = await select([Table2.AttrName2], Table1)
.having(le(Table2.AttrName3, 5)) //optional
.limit(10) //optional
.query(db);
```
Joins:
```javascript
import { INT, onAction } from "dblang"
const TableA = db.newTable("TableA");
const TableB = db.newTable("TableB");
TableA.addAttribute("A1", INT, {
primaryKey: true
});
TableB.addAttribute("B1", INT, {
primaryKey: true,
foreignKey:{
link: TableA.A1,
onDelete: onAction.cascade
}
});
let res = await select([TableA.A1, TableB.B1], innerJoinOn(eq(TableA.A1, Tableb.B1)))
.query(db);
```
#### Insert:
```javascript
import {select} from "dblang"
import { select } from "dblang"
await insert(Table2.AttrName2, Table2.AttrName3)
.add(1, 2)
@ -121,6 +140,8 @@ await insert(Table2.AttrName2, Table2.AttrName3)
#### Update:
```javascript
import { update } from "dblang"
await update(Table2)
.set(Table2.AttrName2, plus(Table2.AttrName2,1))
.set(Table2.AttrName3, minus(Table2.AttrName2,1))
@ -130,6 +151,8 @@ await update(Table2)
#### Remove:
```javascript
import { remove } from "dblang"
await remove(Table2)
.where(geq(Table2.AttrName2, 5))
.query(db);

View file

@ -5,8 +5,6 @@ import { allModifierInput, joinType, onAction, primaryData } from "./types"
export class Handler {
async syncDB(db: DB, handler: Handler, deleteInDB: boolean = false) {
console.log("start sync");
let gd = new QueryBuilder();
gd.addCode(`SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_SCHEMA = `);
gd.addInjection(db.name);