This commit is contained in:
parent
580988e2c0
commit
6901eb91b9
2 changed files with 26 additions and 5 deletions
29
readme.md
29
readme.md
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue