index.js
function attachProperties(schema, paths) {
  paths.forEach(path => {
    const props = path.options.attach.properties;

    if (props[path.path]) {
      (props[path.path].on || []).forEach(on => {

        /**
        * Setup post callbacks
        */
        schema.post(on, function(documents, next) {
          asArray(documents).forEach(function(doc) {
            paths.forEach(function(path) {
              doc[props[path.path].as] = path.enumValues;
            });
          });

          next();
        });
      });
    }
  });
}
function attachProperties(schema, paths) {
  paths.forEach(path => {
    const props = path.options.attach.properties;

    if (props[path.path]) {
      (props[path.path].on || []).forEach(on => {

        /**
        * Setup post callbacks
        */
        schema.post(on, function(documents, next) {
          asArray(documents).forEach(function(doc) {
            paths.forEach(function(path) {
              doc[props[path.path].as] = path.enumValues;
            });
          });

          next();
        });
      });
    }
  });
}
function attachProperties ( schema , paths ) { paths . forEach ( path => { const props = path . options . attach . properties ; if ( props [ path . path ] ) { ( props [ path . path ] . on || [ ] ) . forEach ( on => { /**
        * Setup post callbacks
        */ schema . post ( on , function ( documents , next ) { asArray ( documents ) . forEach ( function ( doc ) { paths . forEach ( function ( path ) { doc [ props [ path . path ] . as ] = path . enumValues ; } ) ; } ) ; next ( ) ; } ) ; } ) ; } } ) ; }
Attach properties to the document
Attach properties to the document