lib/utils.js
function toMongooseArgs(args) {
  // Covert name_first to name: {first}
  let keyDepth = [];
  return (0, _entries2.default)(args).reduce((args, _ref7) => {
    var _ref8 = (0, _slicedToArray3.default)(_ref7, 2);

    let key = _ref8[0];
    let value = _ref8[1];

    keyDepth = key.split('_');
    if (keyDepth.length === 1) return (0, _assign2.default)(args, { [key]: value });
    keyDepth.reduce((args, depth, index) => {
      if (index === keyDepth.length - 1) {
        args[depth] = value;
        return;
      }
      args[depth] = args[depth] || {};
      return args[depth];
    }, args);
    return args;
  }, {});
}
function toMongooseArgs(args) {
  // Covert name_first to name: {first}
  let keyDepth = [];
  return (0, _entries2.default)(args).reduce((args, _ref7) => {
    var _ref8 = (0, _slicedToArray3.default)(_ref7, 2);

    let key = _ref8[0];
    let value = _ref8[1];

    keyDepth = key.split('_');
    if (keyDepth.length === 1) return (0, _assign2.default)(args, { [key]: value });
    keyDepth.reduce((args, depth, index) => {
      if (index === keyDepth.length - 1) {
        args[depth] = value;
        return;
      }
      args[depth] = args[depth] || {};
      return args[depth];
    }, args);
    return args;
  }, {});
}
function toMongooseArgs ( args ) { // Covert name_first to name: {first} let keyDepth = [ ] ; return ( 0 , _entries2 . default ) ( args ) . reduce ( ( args , _ref7 ) => { var _ref8 = ( 0 , _slicedToArray3 . default ) ( _ref7 , 2 ) ; let key = _ref8 [ 0 ] ; let value = _ref8 [ 1 ] ; keyDepth = key . split ( '_' ) ; if ( keyDepth . length === 1 ) return ( 0 , _assign2 . default ) ( args , { [ key ] : value } ) ; keyDepth . reduce ( ( args , depth , index ) => { if ( index === keyDepth . length - 1 ) { args [ depth ] = value ; return ; } args [ depth ] = args [ depth ] || { } ; return args [ depth ] ; } , args ) ; return args ; } , { } ) ; }
Convert args that graphql know to the args that mongoose know
so that the args can be used by mongoose to find or create
Convert args that graphql know to the args that mongoose know so that the args can be used by mongoose to find or create