dt-toolbox 6.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +27 -0
- package/Migration.guide.md +68 -2
- package/README.md +81 -43
- package/README_v.6.x.x.md +1158 -0
- package/package.json +4 -4
- package/src/convertors/index.js +2 -2
- package/src/convertors/tuples.js +3 -3
- package/src/flatData/look.js +12 -5
- package/src/flatObject/extractList.js +47 -0
- package/src/flatObject/index.js +28 -13
- package/src/flatObject/insert.js +16 -6
- package/src/flatObject/model.js +1 -1
- package/src/main.js +5 -1
- package/src/mainLib.js +12 -3
package/Changelog.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
## Release History
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
### 7.1.0 (2023-08-28)
|
|
5
|
+
- [x] Method `extractList` was added;
|
|
6
|
+
- [x] Fix: Method `model` recognizes '**files**' as a model;
|
|
7
|
+
- [x] Fix: Tuple model if data is just an array is wrong;
|
|
8
|
+
- [x] Fix: Convertor to files shows 'root' in the beginning of the path;
|
|
9
|
+
- [x] Fix: Convertor to breadcrumbs shows 'root' in the beginning of the path;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### 7.0.0 (2023-07-15)
|
|
14
|
+
- [x] Method `look` has new arguments: functions `next` and `finish`;
|
|
15
|
+
- [x] To stop iteration on current dt-line `return next()`;
|
|
16
|
+
- [x] To stop iteration on all dt-lines `return finish()`;
|
|
17
|
+
- [x] Method `insert` was renamed to `insertSegment`;
|
|
18
|
+
- [x] Method `listSegments` was added to show list of all segments in dt-object;
|
|
19
|
+
- [x] Method `insertSegment` expect the incoming data as dt-object, but if is not - will assume it as a standard javascript object and will convert it to dt-object automatically;
|
|
20
|
+
- [] Method `insertSegment` can recognize a dt model object.
|
|
21
|
+
- [] Bug: Method `model` doesn't recognize '**files**' as a model;
|
|
22
|
+
- [] Bug: Tuple model if data is just an array is wrong;
|
|
23
|
+
- [] Bug: Convertor to files shows 'root' in the beginning of the path;
|
|
24
|
+
- [] Bug: Convertor to breadcrumbs shows 'root' in the beginning of the path;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
3
28
|
### 6.0.0 (2023-05-12)
|
|
4
29
|
- [x] Version 5 is full rethinking of the idea and rewrite from scratch;
|
|
5
30
|
- [x] Simplified API interface;
|
|
@@ -8,6 +33,8 @@
|
|
|
8
33
|
- [x] Predefined and custom filters for faster data scan;
|
|
9
34
|
- [x] Model and query functions to shape the results;
|
|
10
35
|
|
|
36
|
+
|
|
37
|
+
|
|
11
38
|
### 4.0.7 (2022-03-03)
|
|
12
39
|
- [x] Library '@peter.naydenov/walk' was included as a dependency;
|
|
13
40
|
- [x] Cleaning: Method 'help.generateObject' was removed. Not in use anymore;
|
package/Migration.guide.md
CHANGED
|
@@ -1,9 +1,75 @@
|
|
|
1
1
|
# Migration Guides
|
|
2
2
|
|
|
3
|
+
## From v.6.x.x - v.7.x.x
|
|
4
|
+
Look function can return `next` and `finish` functions. This functions are used to control the flow of the "**look**" function. If you `return next()`, the look function will continue to execute callback with next dt-line object. If you `return finish()`, the look function will end.
|
|
3
5
|
|
|
4
|
-
## From v.4.x.x - v.5.x.x
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
```js
|
|
8
|
+
// was:
|
|
9
|
+
dt.query ( (store) => {
|
|
10
|
+
store.look ( ({name, flatData, breadcrumbs}) => {
|
|
11
|
+
if ( flatData.includes('something') ) {
|
|
12
|
+
// do something
|
|
13
|
+
// return string 'next' to stop iteration on this dt-line
|
|
14
|
+
return 'next'
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// become:
|
|
20
|
+
dt.query ( (store) => {
|
|
21
|
+
store.look ( ({name, flatData, breadcrumbs, next, finish}) => {
|
|
22
|
+
if ( flatData.includes('something') ) {
|
|
23
|
+
// do something
|
|
24
|
+
// return `next()` to stop iteration on current dt-line
|
|
25
|
+
return next ()
|
|
26
|
+
// return `finish()` to stop iteration on all dt-lines (it's a new option)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Method `insert` was renamed to `insertSegment` to be clear that data is not mixed. Segments are separated peaces of data.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
// before
|
|
37
|
+
const dt = dtbox.init ( a );
|
|
38
|
+
dt.insert ( 'specificDataName' b ) // b is a dt-object
|
|
39
|
+
|
|
40
|
+
// after
|
|
41
|
+
const dt = dtbox.init ( a );
|
|
42
|
+
dt.insertSegment ( 'specificDataName' b ) // b is a dt-object
|
|
43
|
+
// it's possible to insert a standard js object but it's not recomended
|
|
44
|
+
// dt.insertSegment ( 'specialDataName', a ) // a is a standard js object
|
|
45
|
+
// also possible to insert a dt model object directly
|
|
46
|
+
// dt.insertSegment ( 'specialDataName', c ) // Where c = b.export(). A dt model object.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Method `listSegments` was added to show list of all segments in dt-object.
|
|
50
|
+
|
|
51
|
+
After version 7.1.x method `extractList` was added. Method helps to extract from dt-object multiple segments and properties, defined in a list. Options are coming as a second argument. Use them to define a model of extracted data.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const
|
|
55
|
+
first = { name: 'first', data: 'first data' }
|
|
56
|
+
, second = { name: 'second', data: 'second data' }
|
|
57
|
+
, third = { name: 'third', data: 'third data' }
|
|
58
|
+
;
|
|
59
|
+
const storage = dtbox.init ( first ); // first will become a root segment
|
|
60
|
+
storage.insertSegment ( 'second', second );
|
|
61
|
+
storage.insertSegment ( 'third', third );
|
|
62
|
+
|
|
63
|
+
const [ a, b c, firstData ] = storage.extractList ( ['first', 'second', 'third', 'data' ], { type: 'std' } ));
|
|
64
|
+
// a -> { name: 'first', data: 'first data' }
|
|
65
|
+
// b -> { name: 'second', data: 'second data' }
|
|
66
|
+
// c -> { name: 'third', data: 'third data' }
|
|
67
|
+
// firstData -> 'first data' // Field 'data' from main dt-line of 'root' segment.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## From v.4.x.x - v.6.x.x
|
|
71
|
+
|
|
72
|
+
The library "dt-toolbox" exist for a full 7 years and now version 6 is coming as full rewrite of the original idea. Difference are more then similarity and better aproach is to read a version 6 documentation first. Then you will find that:
|
|
7
73
|
|
|
8
74
|
- Data creation is very simular;
|
|
9
75
|
- Dt-Object becomes a storage and you can add more data to it;
|
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# DT Toolbox v.
|
|
1
|
+
# DT Toolbox v.7.x.x
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
4
5
|
|
|
6
|
+
- [Documentatation for v.6.x.x is here](htts://github.com/PeterNaydenov/dt-toolbox/blob/master/README_v.6.x.x.md)
|
|
7
|
+
- [Migration guide from v.6.x.x to v.7.x.x](htts://github.com/PeterNaydenov/dt-toolbox/blob/master/MIGRATION.md)
|
|
5
8
|
|
|
6
9
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* New internal data-model;
|
|
11
|
-
* Multiple data inserts;
|
|
12
|
-
* Predefined and custom filters for faster data scan;
|
|
13
|
-
* Model and query functions to shape results;
|
|
10
|
+
## Last Updates
|
|
11
|
+
|
|
12
|
+
After version 7.1.x `dt-object` api has a new method `extractList` that helps to extract a multiple segments or properties, defined as a list. Use '**options**'(the second argument) to define a model of extracted data if needed. Reed about `extractList` bellow.
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
## Description
|
|
17
|
+
|
|
18
18
|
DT-Toolbox is created to simplify the work with deep nested javascript objects. The library was created as an immutable data-storage(dt-object), internally based on data-model called `DT-model`.
|
|
19
19
|
|
|
20
20
|
## What is DT-model?
|
|
@@ -37,6 +37,7 @@ This data-description is easy to read, saved, or transfered.
|
|
|
37
37
|
|
|
38
38
|
## Installation
|
|
39
39
|
Install for node.js projects by writing in your terminal:
|
|
40
|
+
|
|
40
41
|
```
|
|
41
42
|
npm install dt-toolbox
|
|
42
43
|
```
|
|
@@ -53,12 +54,12 @@ import dtbox from 'dt-toolbox'
|
|
|
53
54
|
Use Dt-toolbox methods(init and load) to create a `dt-object`.
|
|
54
55
|
|
|
55
56
|
DT-object:
|
|
56
|
-
- Provides multiple insertion of data
|
|
57
|
+
- Provides multiple insertion of data segments. Data from each insertion stays differentiated;
|
|
57
58
|
- Has prebuilded filters for fast search of data;
|
|
58
59
|
- Can create and register a customized filters for fast search of data;
|
|
59
60
|
- Can apply `query functions` to find, extract and reshape the data;
|
|
60
61
|
- Can apply `model function` to reshape the final result;
|
|
61
|
-
- Can executes 'query' and 'model' function over all available data in the storage (All
|
|
62
|
+
- Can executes 'query' and 'model' function over all available data in the storage (All data segments);
|
|
62
63
|
- Execution of query/model functions will not change anything inside the host dt-object;
|
|
63
64
|
|
|
64
65
|
The **dt-object** contains internally a `dt-storage` object, that is available during call of the 'query' or 'model' functions. Dt-storage have couple of methods for searching data as well can create a new **DT-model** structures and fill them with data.
|
|
@@ -70,7 +71,7 @@ Query functions are returning a **new instance of dt-object** with the result, c
|
|
|
70
71
|
'list' : 'Scan only dt-lines where flatData is an array'
|
|
71
72
|
, 'listObject' : 'Scan objects that are members of array'
|
|
72
73
|
, 'object' : 'Scan just dt-lines where flatData is an object'
|
|
73
|
-
, 'root' : 'Scan only root dt-lines of each data
|
|
74
|
+
, 'root' : 'Scan only root dt-lines of each data segment'
|
|
74
75
|
```
|
|
75
76
|
Filters are very simple functions to build. Here is one example of how we can create filter for finding object with specific key and value in it.
|
|
76
77
|
```js
|
|
@@ -116,13 +117,15 @@ Take a look on the library APIs and see the '**Examples**' section bellow.
|
|
|
116
117
|
### dt-object API Fast Reference
|
|
117
118
|
|
|
118
119
|
```js
|
|
119
|
-
|
|
120
|
+
insertSegment : 'Inserts a new data-segment in the dt-object. Insertion should be provided as a dt-object.'
|
|
120
121
|
, 'export' : 'Returns the DT-model from dt-object - part or full'
|
|
121
122
|
, copy : 'Creates a copy of original provided data'
|
|
122
123
|
, query : 'Executes a "query" function on the dt-object. Returns a new dt-object with the result'
|
|
123
124
|
, model : 'Executes a "model" function on the dt-object. Returns a data model'
|
|
124
125
|
, setupFilter : 'Evaluate data according "filter" function and create a shorter scan list that can be used by "dt-storage" during execution of query and model functions'
|
|
125
126
|
, index : 'Provides a copy of specified dt-line by breadcrumbs'
|
|
127
|
+
, listSegments : 'Returns a list of all segments in dt-object'
|
|
128
|
+
, extractList : 'Extracts a list of segments and/or properties from dt-object'
|
|
126
129
|
```
|
|
127
130
|
|
|
128
131
|
### dt-storage API Fast Reference
|
|
@@ -312,8 +315,8 @@ const walk = dtbox.getWalk ();
|
|
|
312
315
|
## DT-object API
|
|
313
316
|
|
|
314
317
|
|
|
315
|
-
### dt.
|
|
316
|
-
Extend the dt-object with a new data. Insertion should be provided as dt-object.
|
|
318
|
+
### dt.insertSegment ()
|
|
319
|
+
Extend the dt-object with a new data segment. Insertion should be provided as dt-object.
|
|
317
320
|
|
|
318
321
|
```js
|
|
319
322
|
const a = [ // it's a 'file' data-model
|
|
@@ -331,10 +334,10 @@ const a = [ // it's a 'file' data-model
|
|
|
331
334
|
];
|
|
332
335
|
const b = { shoes: [ 'Puma', 'UA' ]}
|
|
333
336
|
const dt = dtbox.init ( a, { model : 'file' }) // create a dt-object
|
|
334
|
-
dt.
|
|
335
|
-
'extra'
|
|
337
|
+
dt.insertSegment (
|
|
338
|
+
'extra' // object name
|
|
336
339
|
, dtbox.init(b) // the extra object
|
|
337
|
-
) // insert to 'dt' storage extra
|
|
340
|
+
) // insert to 'dt' storage data segment named 'extra' with data from 'b' object
|
|
338
341
|
|
|
339
342
|
/**
|
|
340
343
|
dt internal interpretation:
|
|
@@ -369,7 +372,7 @@ dt.insert (
|
|
|
369
372
|
, 'root/shoes/summer' // -> location
|
|
370
373
|
, [] // -> edges
|
|
371
374
|
]
|
|
372
|
-
// ---> Here are the elements that are coming from '
|
|
375
|
+
// ---> Here are the elements that are coming from 'insertSegment'
|
|
373
376
|
, [
|
|
374
377
|
'extra' // -> dt-line name. Object name of insert will become root element for data segment.
|
|
375
378
|
, {} // -> flatData
|
|
@@ -425,7 +428,7 @@ const
|
|
|
425
428
|
, c = { vitamins : [ 'a', 'b', 'c' ]}
|
|
426
429
|
, dt = dtbox.init ( b )
|
|
427
430
|
;
|
|
428
|
-
dt.
|
|
431
|
+
dt.insertSegment ( 'extra', c )
|
|
429
432
|
const deepCopy = dt.copy ()
|
|
430
433
|
// it equal to: const deepCopy = dt.copy ('root')
|
|
431
434
|
const onlyExtra = dt.copy ( 'extra' )
|
|
@@ -454,9 +457,10 @@ function modelFn ( store, a,v,g ) { // optional arguments will come directly aft
|
|
|
454
457
|
as : 'std' // property 'as' will execute final conversion. Model name should be from supported list of the library.
|
|
455
458
|
}
|
|
456
459
|
}
|
|
460
|
+
// Supported model-names are:
|
|
461
|
+
// 'standard', 'std', 'midFlat', 'tuple', 'tuples', 'breadcrumb', 'breadcrumbs'
|
|
457
462
|
|
|
458
463
|
const result = dt.model ( modelFn, a,v,g ) // modelFn is the only required argument. All other arguments are optional.
|
|
459
|
-
|
|
460
464
|
```
|
|
461
465
|
|
|
462
466
|
### dt.setupFilter ()
|
|
@@ -505,8 +509,39 @@ const [ name, flatData, breadcrumbs, edges ] = dt.index ( br )
|
|
|
505
509
|
// edges === []
|
|
506
510
|
```
|
|
507
511
|
|
|
512
|
+
### dt.listSegments ()
|
|
508
513
|
|
|
514
|
+
Returns a list of all data segment names. Result is always an array with at least one element - 'root'.
|
|
509
515
|
|
|
516
|
+
```js
|
|
517
|
+
dt.listSegments ()
|
|
518
|
+
// [ 'root', 'extra' ]
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### dt.extractList ()
|
|
522
|
+
|
|
523
|
+
After version 7.1.x method `extractList` was added. Method can extract a list of segments and properties as a single instruction. Options are coming as a second argument. Use optioins(the second argument) to define a model of extracted data if needed. Modeling is applied only on objects.
|
|
524
|
+
|
|
525
|
+
If requested segment or property is not available, response will be '**null**'.
|
|
526
|
+
Segments have priority over properties. If there is a segment with the same name as a property, segment will be extracted.
|
|
527
|
+
|
|
528
|
+
```js
|
|
529
|
+
const
|
|
530
|
+
first = { name: 'first', data: 'first data' }
|
|
531
|
+
, second = { name: 'second', data: 'second data' }
|
|
532
|
+
, third = { name: 'third', data: 'third data' }
|
|
533
|
+
;
|
|
534
|
+
const storage = dtbox.init ( first ); // first will become a root segment
|
|
535
|
+
storage.insertSegment ( 'second', second );
|
|
536
|
+
storage.insertSegment ( 'third', third );
|
|
537
|
+
|
|
538
|
+
const [ a, b c, firstData, otherData ] = storage.extractList ( ['first', 'second', 'third', 'data', 'secondData' ], { type: 'std' } ));
|
|
539
|
+
// a -> { name: 'first', data: 'first data' }
|
|
540
|
+
// b -> { name: 'second', data: 'second data' }
|
|
541
|
+
// c -> { name: 'third', data: 'third data' }
|
|
542
|
+
// firstData -> 'first data' // Field 'data' from main dt-line of 'root' segment.
|
|
543
|
+
// otherData -> null // There is no 'secondData' in 'root' segment. No segment 'secondData' as well.
|
|
544
|
+
```
|
|
510
545
|
|
|
511
546
|
|
|
512
547
|
|
|
@@ -547,11 +582,13 @@ const result = dt.query ( store => {
|
|
|
547
582
|
, breadcrumbs // breadcrumbs for dt-line;
|
|
548
583
|
, links // List of tuples [[parent, child],...]. Parent and child are the dt-line names;
|
|
549
584
|
, empty // Will present only if object has no properties. Empty flatData for dt-line.
|
|
585
|
+
, next // Function that can be returned to move to next dt-line
|
|
586
|
+
, finish // Function that can be returned to stop execution of look function
|
|
550
587
|
}) => {
|
|
551
588
|
//... body of look function
|
|
552
589
|
// Move fast to next dt-line by returning a string 'next'
|
|
553
|
-
return
|
|
554
|
-
// unconditional return
|
|
590
|
+
return next ()
|
|
591
|
+
// unconditional `return next()` will executes the 'look' function once per dt-line
|
|
555
592
|
})
|
|
556
593
|
})
|
|
557
594
|
```
|
|
@@ -578,10 +615,10 @@ const
|
|
|
578
615
|
, res = dt.query ( store => {
|
|
579
616
|
store
|
|
580
617
|
.from ( 'root/personal/hobbies' )
|
|
581
|
-
.look ( ({name}) => {
|
|
618
|
+
.look ( ({name, next }) => {
|
|
582
619
|
console.log ( name )
|
|
583
620
|
// -> hobbies, music, sport
|
|
584
|
-
return
|
|
621
|
+
return next () // because we want to iterate once on each dt-line
|
|
585
622
|
})
|
|
586
623
|
});
|
|
587
624
|
```
|
|
@@ -593,7 +630,7 @@ List of predefined filters:
|
|
|
593
630
|
- 'list' : Scan only dt-lines where flatData is an array;
|
|
594
631
|
- 'listObject' : Scan objects that are members of array;
|
|
595
632
|
- 'object' : Scan just dt-lines where flatData is an object;
|
|
596
|
-
- 'root' : Scan only root dt-lines of each data
|
|
633
|
+
- 'root' : Scan only root dt-lines of each data segment;
|
|
597
634
|
|
|
598
635
|
If filter do not exist, look function will be executed on each dt-line.
|
|
599
636
|
|
|
@@ -616,10 +653,10 @@ const
|
|
|
616
653
|
, res = dt.query ( store => {
|
|
617
654
|
store
|
|
618
655
|
.use ( 'object' ) // predefined filter 'object'
|
|
619
|
-
.look ( ({name}) => {
|
|
656
|
+
.look ( ({name, next }) => {
|
|
620
657
|
console.log ( name )
|
|
621
658
|
// -> root, personal, hobbies
|
|
622
|
-
return
|
|
659
|
+
return next () // because we want to iterate once on each dt-line
|
|
623
660
|
})
|
|
624
661
|
});
|
|
625
662
|
```
|
|
@@ -650,10 +687,10 @@ const
|
|
|
650
687
|
, res = dt.query ( store => {
|
|
651
688
|
store
|
|
652
689
|
.get ( 'root/friends' )
|
|
653
|
-
.look ( ({flatData}) => {
|
|
690
|
+
.look ( ({ flatData, next }) => {
|
|
654
691
|
console.log ( flatData )
|
|
655
692
|
// -> [ 'Ivan', 'Dobroslav', 'Stefan' ]
|
|
656
|
-
return
|
|
693
|
+
return next () // because we want to iterate once on each dt-line
|
|
657
694
|
})
|
|
658
695
|
});
|
|
659
696
|
```
|
|
@@ -682,10 +719,10 @@ const
|
|
|
682
719
|
, res = dt.query ( store => {
|
|
683
720
|
store
|
|
684
721
|
.find ( 'music' )
|
|
685
|
-
.look ( ({flatData}) => {
|
|
722
|
+
.look ( ({flatData, next }) => {
|
|
686
723
|
console.log ( flatData )
|
|
687
724
|
// -> [ 'punk', 'ska', 'metal', 'guitar' ]
|
|
688
|
-
return
|
|
725
|
+
return next () // because we want to iterate once on each dt-line
|
|
689
726
|
})
|
|
690
727
|
});
|
|
691
728
|
```
|
|
@@ -714,12 +751,12 @@ const
|
|
|
714
751
|
, res = dt.query ( store => {
|
|
715
752
|
store
|
|
716
753
|
.like ( 'per' )
|
|
717
|
-
.look ( ({flatData, breadcrumbs}) => {
|
|
754
|
+
.look ( ({flatData, breadcrumbs, next }) => {
|
|
718
755
|
console.log ( flatData )
|
|
719
756
|
// -> { age: 49, eyes: 'blue' }
|
|
720
757
|
console.log ( breadcrumbs )
|
|
721
758
|
// -> 'root/personal'
|
|
722
|
-
return
|
|
759
|
+
return next () // because we want to iterate once on each dt-line
|
|
723
760
|
})
|
|
724
761
|
});
|
|
725
762
|
```
|
|
@@ -1009,13 +1046,13 @@ const result = dt.query ( store => {
|
|
|
1009
1046
|
store.set ( 'root', []) // setup a root array element
|
|
1010
1047
|
store
|
|
1011
1048
|
.use ( 'listObject' ) // use only objects that are members of array
|
|
1012
|
-
.look ( ({ name, flatData }) => {
|
|
1049
|
+
.look ( ({ name, flatData, next }) => {
|
|
1013
1050
|
if ( flatData.age < 40 ) {
|
|
1014
1051
|
store.set ( i, flatData )
|
|
1015
1052
|
connectBuffer.push ( `root/${i}` )
|
|
1016
1053
|
i++
|
|
1017
1054
|
}
|
|
1018
|
-
return
|
|
1055
|
+
return next ()
|
|
1019
1056
|
})
|
|
1020
1057
|
store.connect ( connectBuffer )
|
|
1021
1058
|
})
|
|
@@ -1044,9 +1081,9 @@ const result = dt.query ( store => {
|
|
|
1044
1081
|
store.set ( 'root', [])
|
|
1045
1082
|
store
|
|
1046
1083
|
.use ( 'listObject' ) // use only objects that are members of array
|
|
1047
|
-
.look ( ({ flatData }) => {
|
|
1084
|
+
.look ( ({ flatData, next }) => {
|
|
1048
1085
|
if ( flatData.age < 40 ) store.push ( 'root', flatData.name )
|
|
1049
|
-
return
|
|
1086
|
+
return next ()
|
|
1050
1087
|
})
|
|
1051
1088
|
})
|
|
1052
1089
|
.model ( () => ({as:'std'}) )
|
|
@@ -1075,10 +1112,10 @@ Return an object with two groups
|
|
|
1075
1112
|
store.connect ([ 'root/under40', 'root/over40' ])
|
|
1076
1113
|
store
|
|
1077
1114
|
.use ( 'listObject' ) // use only objects that are members of array
|
|
1078
|
-
.look ( ({ flatData }) => {
|
|
1115
|
+
.look ( ({ flatData, next }) => {
|
|
1079
1116
|
let location = ( flatData.age > 40 ) ? 'over40' : 'under40';
|
|
1080
1117
|
store.push ( location, flatData.name )
|
|
1081
|
-
return
|
|
1118
|
+
return next ()
|
|
1082
1119
|
})
|
|
1083
1120
|
})
|
|
1084
1121
|
.model ( () => ({ as : 'std'}))
|
|
@@ -1102,10 +1139,10 @@ console.log ( result )
|
|
|
1102
1139
|
|
|
1103
1140
|
```js
|
|
1104
1141
|
const result = dt.query ( store => {
|
|
1105
|
-
store.look ( ({ name, flatData, breadcrumbs }) => {
|
|
1142
|
+
store.look ( ({ name, flatData, breadcrumbs, next }) => {
|
|
1106
1143
|
store.set ( name, flatData )
|
|
1107
1144
|
if ( breadcrumbs.includes('/') ) store.connect ([breadcrumbs])
|
|
1108
|
-
return
|
|
1145
|
+
return next ()
|
|
1109
1146
|
})
|
|
1110
1147
|
})
|
|
1111
1148
|
.model ( () => ({as:'std'}))
|
|
@@ -1139,8 +1176,9 @@ console.log ( result )
|
|
|
1139
1176
|
|
|
1140
1177
|
|
|
1141
1178
|
## External Links
|
|
1142
|
-
- [Migration guide](https://github.com/PeterNaydenov/dt-toolbox/blob/master/Migration.guide.md)
|
|
1143
1179
|
- [History of changes](https://github.com/PeterNaydenov/dt-toolbox/blob/master/Changelog.md)
|
|
1180
|
+
- [Migration guide](https://github.com/PeterNaydenov/dt-toolbox/blob/master/Migration.guide.md)
|
|
1181
|
+
- [DT-Queries. Some useful query functions for DT-Toolbox](https://github.com/PeterNaydenov/dt-queries)
|
|
1144
1182
|
- [Documentation v.4.x.x](https://github.com/PeterNaydenov/dt-toolbox/blob/master/README_v.4.x.x.md)
|
|
1145
1183
|
- [Documentation v.2.x.x](https://github.com/PeterNaydenov/dt-toolbox/blob/master/README_v.2.x.x.md)
|
|
1146
1184
|
|