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] remove Query
- [x] create Schema - [x] create Schema
- [x] remove unused Schema - [x] remove unused Schema
- [ ] joins - [x] joins
- [ ] change Schema - [ ] change Schema
- [ ] Key-Value Store Shortcut - [ ] Key-Value Store Shortcut
- [ ] Views - [ ] Views
@ -101,7 +101,26 @@ let res = await select([Table2.AttrName2], Table1)
.having(le(Table2.AttrName3, 5)) //optional .having(le(Table2.AttrName3, 5)) //optional
.limit(10) //optional .limit(10) //optional
.query(db); .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: #### Insert:
@ -121,6 +140,8 @@ await insert(Table2.AttrName2, Table2.AttrName3)
#### Update: #### Update:
```javascript ```javascript
import { update } from "dblang"
await update(Table2) await update(Table2)
.set(Table2.AttrName2, plus(Table2.AttrName2,1)) .set(Table2.AttrName2, plus(Table2.AttrName2,1))
.set(Table2.AttrName3, minus(Table2.AttrName2,1)) .set(Table2.AttrName3, minus(Table2.AttrName2,1))
@ -130,6 +151,8 @@ await update(Table2)
#### Remove: #### Remove:
```javascript ```javascript
import { remove } from "dblang"
await remove(Table2) await remove(Table2)
.where(geq(Table2.AttrName2, 5)) .where(geq(Table2.AttrName2, 5))
.query(db); .query(db);

View file

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