@onehat/data 1.6.9 → 1.6.10

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.
@@ -718,6 +718,10 @@ describe('Repository Base', function() {
718
718
  // deleteById
719
719
  // deleteDirty
720
720
  // deletePhantom
721
+ // undeleteByIx
722
+ // undeleteByRange
723
+ // undeleteBy
724
+ // undeleteById
721
725
 
722
726
  });
723
727
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/Entity.js CHANGED
@@ -1077,7 +1077,7 @@ class Entity extends EventEmitter {
1077
1077
  }
1078
1078
 
1079
1079
  /**
1080
- * Tells the Repository to UNdelete this entity.
1080
+ * Marks a deleted entity as undeleted.
1081
1081
  * Only works when autoSave is off for the containing repository
1082
1082
  * @fires delete
1083
1083
  */
@@ -1478,6 +1478,44 @@ export default class Repository extends EventEmitter {
1478
1478
  await this.delete(this.getPhantom());
1479
1479
  }
1480
1480
 
1481
+ /**
1482
+ * Deletes a single Entity by its index (zero-indexed) on the current page
1483
+ * @param {integer} ix - Index
1484
+ * @return {object} entity - Entity
1485
+ */
1486
+ undeleteByIx = async (ix) => {
1487
+ await this.undelete(this.getByIx(ix));
1488
+ }
1489
+
1490
+ /**
1491
+ * Deletes multiple Entities by their range of indices
1492
+ * (zero-indexed) on the current page
1493
+ * @param {integer} startIx - Index
1494
+ * @param {integer} endIx - Index (inclusive)
1495
+ * @return {array} entities - Array of Entities
1496
+ */
1497
+ undeleteByRange = async (startIx, endIx) => {
1498
+ await this.undelete(this.getByRange(startIx, endIx));
1499
+ }
1500
+
1501
+ /**
1502
+ * Remove multiple Entities by supplied filter function
1503
+ * @param {function} fn - Filter function to apply to all entities
1504
+ * @return {Entity[]} Entities that passed through filter
1505
+ */
1506
+ undeleteBy = async (filter) => {
1507
+ await this.undelete(this.getBy(filter));
1508
+ }
1509
+
1510
+ /**
1511
+ * Remove a single Entity by its id
1512
+ * @param {integer} id - id of record to retrieve
1513
+ * @return {Entity} The Entity with matching id
1514
+ */
1515
+ undeleteById = async (id) => {
1516
+ await this.undelete(this.getById(id));
1517
+ }
1518
+
1481
1519
 
1482
1520
 
1483
1521