controller.js
function(query) {
    var result = {};
    if (!_.isObject(query) || _.isEmpty(query)) {
      return result;
    }

    // timestamp might be in `ms` or `s`
    _.forEach(query, function(timestamp, operator) {
      if (!_.includes(['gt', 'gte', 'lt', 'lte', 'ne'], operator)) {
        return;
      }

      // Timestamp must be an integer
      timestamp = _.parseInt(timestamp);
      if (_.isNaN(timestamp)) {
        return;
      }

      // Convert seconds to milliseconds
      timestamp = Mixins.isUnixTime(timestamp) ? timestamp * 1000 : timestamp;

      result['$' + operator] = timestamp;
    });

    debug.info(
      '#_buildTimestampQuery with query: %s and result: %s',
      JSON.stringify(query),
      JSON.stringify(result)
    );
    return result;
  }
function(query) {
    var result = {};
    if (!_.isObject(query) || _.isEmpty(query)) {
      return result;
    }

    // timestamp might be in `ms` or `s`
    _.forEach(query, function(timestamp, operator) {
      if (!_.includes(['gt', 'gte', 'lt', 'lte', 'ne'], operator)) {
        return;
      }

      // Timestamp must be an integer
      timestamp = _.parseInt(timestamp);
      if (_.isNaN(timestamp)) {
        return;
      }

      // Convert seconds to milliseconds
      timestamp = Mixins.isUnixTime(timestamp) ? timestamp * 1000 : timestamp;

      result['$' + operator] = timestamp;
    });

    debug.info(
      '#_buildTimestampQuery with query: %s and result: %s',
      JSON.stringify(query),
      JSON.stringify(result)
    );
    return result;
  }
function ( query ) { var result = { } ; if ( ! _ . isObject ( query ) || _ . isEmpty ( query ) ) { return result ; } // timestamp might be in `ms` or `s` _ . forEach ( query , function ( timestamp , operator ) { if ( ! _ . includes ( [ 'gt' , 'gte' , 'lt' , 'lte' , 'ne' ] , operator ) ) { return ; } // Timestamp must be an integer timestamp = _ . parseInt ( timestamp ) ; if ( _ . isNaN ( timestamp ) ) { return ; } // Convert seconds to milliseconds timestamp = Mixins . isUnixTime ( timestamp ) ? timestamp * 1000 : timestamp ; result [ '$' + operator ] = timestamp ; } ) ; debug . info ( '#_buildTimestampQuery with query: %s and result: %s' , JSON . stringify ( query ) , JSON . stringify ( result ) ) ; return result ; }
Converts a url query object containing time range data
into a Mongo compatible query

Note:

- timestamps can be either milliseconds or seconds
- timestamps can be strings, they will be parsed into Integers

Example:

{
gt: 1405494000,
lt: 1431327600
}

Possible Keys:

- `gt` Greater than
- `gte` Greather than or equal
- `lt` Less than
- `lte` Less than or equal
- `ne` Not equal

@param {Object} query
@return {Object}
Converts a url query object containing time range data into a Mongo compatible query