electrodb 1.8.1 → 1.8.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrodb",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/entity.js CHANGED
@@ -899,6 +899,18 @@ class Entity {
899
899
  return {parameters, config};
900
900
  }
901
901
 
902
+ addListeners(logger) {
903
+ this.eventManager.add(logger);
904
+ }
905
+
906
+ _addLogger(logger) {
907
+ if (validations.isFunction(logger)) {
908
+ this.addListeners(logger);
909
+ } else {
910
+ throw new e.ElectroError(e.ErrorCodes.InvalidLoggerProvided, `Logger must be of type function`);
911
+ }
912
+ }
913
+
902
914
  _getPrimaryIndexFieldNames() {
903
915
  let hasSortKey = this.model.lookup.indexHasSortKeys[TableIndex];
904
916
  let accessPattern = this.model.translations.indexes.fromIndexToAccessPattern[TableIndex];
package/src/service.js CHANGED
@@ -191,6 +191,14 @@ class Service {
191
191
  entity._setClient(options.client);
192
192
  }
193
193
 
194
+ if (options.logger) {
195
+ entity._addLogger(options.logger);
196
+ }
197
+
198
+ if (options.listeners) {
199
+ entity.addListeners(options.listeners);
200
+ }
201
+
194
202
  if (this._modelVersion === ModelVersions.beta && this.service.version) {
195
203
  entity.model.version = this.service.version;
196
204
  }