@onehat/data 1.6.11 → 1.6.12

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.
@@ -630,6 +630,15 @@ describe('Repository Base', function() {
630
630
  expect(_.isEqual(entity, dirty[0])).to.be.true;
631
631
  });
632
632
 
633
+ it('isDirty', function() {
634
+ expect(this.repository.isDirty).to.be.false;
635
+
636
+ this.repository.setAutoSave(false);
637
+ const entity = this.repository.getByIx(0);
638
+ entity.value = 'test';
639
+ expect(this.repository.isDirty).to.be.true;
640
+ });
641
+
633
642
  it('getDeleted', function() {
634
643
  this.repository.setAutoSave(false);
635
644
  const entity = this.repository.getByIx(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.6.11",
3
+ "version": "1.6.12",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1181,6 +1181,18 @@ export default class Repository extends EventEmitter {
1181
1181
  return !_.isNil(this.getById(idOrEntity));
1182
1182
  }
1183
1183
 
1184
+ /**
1185
+ * Getter of isDirty for this Repository.
1186
+ * Returns true if any Entities within it are dirty
1187
+ * @return {boolean} isDirty
1188
+ */
1189
+ get isDirty() {
1190
+ if (this.isDestroyed) {
1191
+ throw Error('this.isDirty is no longer valid. Repository has been destroyed.');
1192
+ }
1193
+ return !!this.getDirty().length;
1194
+ }
1195
+
1184
1196
  /**
1185
1197
  * Convenience function
1186
1198
  * Alias for isInRepository