@onyx.dev/onyx-database 0.1.6 → 0.1.9
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/README.md +1 -1
- package/dist/index.cjs +27 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -4
- package/dist/index.d.ts +18 -4
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -582,13 +582,36 @@ var QueryResults = class extends Array {
|
|
|
582
582
|
/**
|
|
583
583
|
* Iterates over each record on the current page only.
|
|
584
584
|
* @param action - Function to invoke for each record.
|
|
585
|
+
* @param thisArg - Optional `this` binding for the callback.
|
|
585
586
|
* @example
|
|
586
587
|
* ```ts
|
|
587
588
|
* results.forEachOnPage(u => console.log(u.id));
|
|
588
589
|
* ```
|
|
589
590
|
*/
|
|
590
|
-
forEachOnPage(action) {
|
|
591
|
-
|
|
591
|
+
forEachOnPage(action, thisArg) {
|
|
592
|
+
super.forEach((value, index) => {
|
|
593
|
+
action.call(thisArg, value, index, this);
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Iterates over every record across all pages sequentially.
|
|
598
|
+
* @param action - Function executed for each record. Returning `false`
|
|
599
|
+
* stops iteration early.
|
|
600
|
+
* @param thisArg - Optional `this` binding for the callback.
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* await results.forEach(u => {
|
|
604
|
+
* console.log(u.id);
|
|
605
|
+
* });
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
forEach(action, thisArg) {
|
|
609
|
+
let index = 0;
|
|
610
|
+
return this.forEachAll(async (item) => {
|
|
611
|
+
const result = await action.call(thisArg, item, index, this);
|
|
612
|
+
index += 1;
|
|
613
|
+
return result;
|
|
614
|
+
});
|
|
592
615
|
}
|
|
593
616
|
/**
|
|
594
617
|
* Iterates over every record across all pages sequentially.
|
|
@@ -982,7 +1005,7 @@ var OnyxDatabaseImpl = class {
|
|
|
982
1005
|
null,
|
|
983
1006
|
this.defaultPartition
|
|
984
1007
|
);
|
|
985
|
-
qb.
|
|
1008
|
+
qb.select(...fields);
|
|
986
1009
|
return qb;
|
|
987
1010
|
}
|
|
988
1011
|
cascade(...relationships) {
|
|
@@ -1189,7 +1212,7 @@ var QueryBuilderImpl = class {
|
|
|
1189
1212
|
this.table = table;
|
|
1190
1213
|
return this;
|
|
1191
1214
|
}
|
|
1192
|
-
|
|
1215
|
+
select(...fields) {
|
|
1193
1216
|
const flat = fields.flatMap((f) => Array.isArray(f) ? f : [f]);
|
|
1194
1217
|
this.fields = flat.length > 0 ? flat : null;
|
|
1195
1218
|
return this;
|