Skip to content

Commit a202ade

Browse files
author
Konrad Lisiczyński
committed
Prettiify readme
1 parent 7e15caa commit a202ade

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/normy/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,21 +387,34 @@ How to do it? Well, as operation value, we do not just pass names of array types
387387
This way we can pass a property like `index` for operations requiring those. To insert this object to multiple arrays, of course we do:
388388

389389
```ts
390-
{ id: '2', name: 'New book', __insert: { arrayTypes: ['books', 'favouriteBooks'], index: 1 } }
390+
{
391+
id: '2',
392+
name: 'New book',
393+
_insert: { arrayTypes: ['books', 'favouriteBooks'], index: 1 },
394+
}
391395
```
392396

393397
So like before, we can just pass array of array types. Ok, but what, if we need to set different indexes for different array types?
394398

395399
```ts
396-
{ id: '2', name: 'New book', __insert: [{ arrayType: 'books', index: 1 }, { arrayType: 'favouriteBooks', index: 2 }] }
400+
{
401+
id: '2',
402+
name: 'New book',
403+
__insert: [{ arrayType: 'books', index: 1 }, { arrayType: 'favouriteBooks', index: 2 }],
404+
}
397405
```
398406

399407
As you can see, you just pass array of operation configs, so that each array type can have dedicated properties.
400408

401409
And what, if you would like to multiple operations to one node? Easy:
402410

403411
```ts
404-
{ id: '2', name: 'New book', __append: 'favouriteBooks', __insert: { arrayTypes: 'books', index: 1 } }
412+
{
413+
id: '2',
414+
name: 'New book',
415+
__append: 'favouriteBooks',
416+
__insert: { arrayTypes: 'books', index: 1 },
417+
}
405418
```
406419

407420
You just add multiple meta operation properties to the same object.

0 commit comments

Comments
 (0)