How to use the dotty.put function in dotty

To help you get started, we’ve selected a few dotty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adrai / node-cqrs-domain / lib / definitions / aggregate.js View on Github external
dotty.put(evt, aggregate.definitions.event.payload, payload);
    }

    if (!!aggregate.definitions.event.meta && !!aggregate.definitions.command.meta) {
      var commandMeta = dotty.get(cmd, aggregate.definitions.command.meta);
      var userAddedMeta = dotty.get(evt, aggregate.definitions.event.meta);
      var meta = (commandMeta || userAddedMeta) && _.extend({}, commandMeta, userAddedMeta);
      dotty.put(evt, aggregate.definitions.event.meta, meta);
    }

    dotty.put(evt, aggregate.definitions.event.aggregateId, aggregateModel.id);
    dotty.put(evt, aggregate.definitions.event.correlationId, dotty.get(cmd, aggregate.definitions.command.id));

    if (!!aggregate.definitions.event.version) {
      if (_.isNumber(version)) {
        dotty.put(evt, aggregate.definitions.event.version, version);
      }

      if (!dotty.exists(evt, aggregate.definitions.event.version)) {
        // if version is not defined in event, search the latest version number...
        var evtName = dotty.get(evt, aggregate.definitions.event.name);
        var maxVersion = _.reduce(aggregate.getEvents(), function (res, e) {
          if (e.name !== evtName) {
            return res;
          }

          var v = e.version || 0;
          if (v > res) {
            return v;
          }
          return res;
        }, 0);
github adrai / node-cqrs-eventdenormalizer / lib / definitions / viewBuilder.js View on Github external
generateNotification: function (evt, vm) {
    var notification = {};

    // event
    if (!!this.definitions.notification.meta && !!this.definitions.event.meta) {
      dotty.put(notification, this.definitions.notification.meta, _.cloneDeep(dotty.get(evt, this.definitions.event.meta)));
    }
    if (!!this.definitions.notification.eventId && !!this.definitions.event.id) {
      dotty.put(notification, this.definitions.notification.eventId, dotty.get(evt, this.definitions.event.id));
    }
    if (!!this.definitions.notification.event && !!this.definitions.event.name) {
      dotty.put(notification, this.definitions.notification.event, dotty.get(evt, this.definitions.event.name));
    }
    if (!!this.definitions.notification.aggregateId && !!this.definitions.event.aggregateId) {
      dotty.put(notification, this.definitions.notification.aggregateId, dotty.get(evt, this.definitions.event.aggregateId));
    }
    if (!!this.definitions.notification.aggregate && !!this.definitions.event.aggregate) {
      dotty.put(notification, this.definitions.notification.aggregate, dotty.get(evt, this.definitions.event.aggregate));
    }
    if (!!this.definitions.notification.context && !!this.definitions.event.context) {
      dotty.put(notification, this.definitions.notification.context, dotty.get(evt, this.definitions.event.context));
    }
    if (!!this.definitions.notification.revision && !!this.definitions.event.revision) {
      dotty.put(notification, this.definitions.notification.revision, dotty.get(evt, this.definitions.event.revision));
    }
github adrai / node-cqrs-domain / lib / definitions / aggregate.js View on Github external
evt = name;
      }
    } else {
      evt = {};
      dotty.put(evt, aggregate.definitions.event.name, name);
      dotty.put(evt, aggregate.definitions.event.payload, payload);
    }

    if (!!aggregate.definitions.event.meta && !!aggregate.definitions.command.meta) {
      var commandMeta = dotty.get(cmd, aggregate.definitions.command.meta);
      var userAddedMeta = dotty.get(evt, aggregate.definitions.event.meta);
      var meta = (commandMeta || userAddedMeta) && _.extend({}, commandMeta, userAddedMeta);
      dotty.put(evt, aggregate.definitions.event.meta, meta);
    }

    dotty.put(evt, aggregate.definitions.event.aggregateId, aggregateModel.id);
    dotty.put(evt, aggregate.definitions.event.correlationId, dotty.get(cmd, aggregate.definitions.command.id));

    if (!!aggregate.definitions.event.version) {
      if (_.isNumber(version)) {
        dotty.put(evt, aggregate.definitions.event.version, version);
      }

      if (!dotty.exists(evt, aggregate.definitions.event.version)) {
        // if version is not defined in event, search the latest version number...
        var evtName = dotty.get(evt, aggregate.definitions.event.name);
        var maxVersion = _.reduce(aggregate.getEvents(), function (res, e) {
          if (e.name !== evtName) {
            return res;
          }

          var v = e.version || 0;
github adrai / node-cqrs-domain / lib / domain.js View on Github external
if (!!this.definitions.command.meta && !!this.definitions.event.meta) {
      dotty.put(evt, this.definitions.event.meta, dotty.get(cmd, this.definitions.command.meta));
    }

    dotty.put(evt, this.definitions.event.correlationId, dotty.get(cmd, this.definitions.command.id));
    dotty.put(evt, this.definitions.event.name, this.options.commandRejectedEventName);
    dotty.put(evt, this.definitions.event.id, dotty.get(cmd, this.definitions.command.id) + '_rejected');
    dotty.put(evt, this.definitions.event.aggregateId, dotty.get(cmd, this.definitions.command.aggregateId));

    if (!!this.definitions.command.aggregate && !!this.definitions.event.aggregate) {
      dotty.put(evt, this.definitions.event.aggregate, dotty.get(cmd, this.definitions.command.aggregate));
    }

    if (!!this.definitions.command.context && !!this.definitions.event.context) {
      dotty.put(evt, this.definitions.event.context, dotty.get(cmd, this.definitions.command.context));
    }

    if (err instanceof ValidationError || err instanceof BusinessRuleError ||
        err instanceof AggregateDestroyedError || err instanceof AggregateConcurrencyError ||
        err instanceof DuplicateCommandError) {
      dotty.put(evt, this.definitions.event.payload, {
        command: cmd,
        reason: {
          name: err.name,
          message: err.message,
          more: err.more
        }
      });

      if (!!this.definitions.event.revision && dotty.get(evt, this.definitions.event.revision) === undefined && err.more && err.more.aggregateRevision > -1) {
        dotty.put(evt, this.definitions.event.revision, err.more.aggregateRevision);
github uber / lint-trap / set-rules.js View on Github external
Object.keys(diffs).forEach(function applyDiff(diffKey) {
        var value = diffs[diffKey];
        dotty.put(content, diffKey, value);
    });
    jf.writeFileSync(jsonPath, content);
github adrai / node-cqrs-eventdenormalizer / lib / definitions / viewBuilder.js View on Github external
self.getNewId(function (err, newId) {
          if (err) {
            debug(err);
            return callback(err);
          }

          dotty.put(notification, self.definitions.notification.id, newId);

          self.saveViewModel(vm, function (err) {
            if (err) {
              debug(err);

              if (err instanceof ConcurrencyError) {
                retry(callback);
                return;
              }

              return callback(err);
            }

            if (!self.options.callOnAfterCommitDuringReplay && self.collection.isReplaying) {
              return callback(null, notification);
            }
github adrai / node-cqrs-domain / lib / definitions / aggregate.js View on Github external
aggregateModel.set = function () {
      AggregateModel.prototype.set.apply(aggregateModel, _.toArray(arguments));
    };

    var evt;

    if (!payload) {
      if (_.isString(name)) {
        evt = {};
        dotty.put(evt, aggregate.definitions.event.name, name);
      } else if (_.isObject(name)) {
        evt = name;
      }
    } else {
      evt = {};
      dotty.put(evt, aggregate.definitions.event.name, name);
      dotty.put(evt, aggregate.definitions.event.payload, payload);
    }

    if (!!aggregate.definitions.event.meta && !!aggregate.definitions.command.meta) {
      var commandMeta = dotty.get(cmd, aggregate.definitions.command.meta);
      var userAddedMeta = dotty.get(evt, aggregate.definitions.event.meta);
      var meta = (commandMeta || userAddedMeta) && _.extend({}, commandMeta, userAddedMeta);
      dotty.put(evt, aggregate.definitions.event.meta, meta);
    }

    dotty.put(evt, aggregate.definitions.event.aggregateId, aggregateModel.id);
    dotty.put(evt, aggregate.definitions.event.correlationId, dotty.get(cmd, aggregate.definitions.command.id));

    if (!!aggregate.definitions.event.version) {
      if (_.isNumber(version)) {
        dotty.put(evt, aggregate.definitions.event.version, version);
github adrai / node-viewmodel / lib / viewmodel.js View on Github external
set: function (data) {
    if (arguments.length === 2) {
      dotty.put(this.attributes, arguments[0], arguments[1]);
    } else if (_.isObject(data)) {
      for (var m in data) {
        dotty.put(this.attributes, m, data[m]);
      }
    }
  },
github adrai / node-cqrs-domain / lib / definitions / aggregate.js View on Github external
self.getNewId(function (err, id) {
          if (err) {
            return callback(err);
          }

          dotty.put(evt, self.definitions.event.id, id);
          callback(null);
        });
      }, function (err) {
github siphomateke / huawei-router-api / src / config.js View on Github external
setConfig(path, value) {
    dotty.put(this.api, path, value);
  },

dotty

Access properties of nested objects using dot-path notation

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Popular dotty functions