Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
BibiFock committed Aug 23, 2020
1 parent cc1e57f commit 52df9ad
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ vegeData.migrate()

## Model

### Defintion
### Definition
```js
const model = vegeData.model.init({
fields: ['id', 'name', 'status', ... ],
Expand Down Expand Up @@ -85,15 +85,26 @@ import { helpers } from 'vege-data';
// concat value
model.queries.select()
.append(' WHERE id IN (')
.append(helpers.concatValue([1, 2, 3]))
.append(helpers.concatValues([1, 2, 3]))

// custom element
const items = [{ id: 1}, { id: 2 }];
model.queries.select()
.append(' WHERE id IN (')
.append(helpers.concatValue(items, ({ id }) => id))
.append(helpers.concatValues(items, ({ id }) => id))
.append(')');

// custom join
const conds = { name: 'goku', type: 'sayan' };
model.queries.select()
.append(
helpers.concatValues(
Object.keys(conds),
(key) => conds[key],
(index) => i > 0 ? ' AND ' : ' WHERE '
)
)

```


Expand Down

0 comments on commit 52df9ad

Please sign in to comment.