ra-scripts/models/partner.js
function(argv, context, callback) {
  return MongoClient.connect(mongoHost, function(err, db) {
    if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); }

    var partnersDb  = db.collection('partners');
    var partnerId   = argvGet(argv, 'partner-id,partner');

    var item = {};

    _.each(argv, (value, key) => {
      sg.setOnn(item, ['$set', sg.toCamelCase(key)], sg.smartValue(value));
    });

    everbose(2, `Upserting partner: ${partnerId}`);
    return partnersDb.updateOne({partnerId}, item, {upsert:true}, function(err, result) {
      if (err)  { console.error(err); }

      db.close();
      return callback(err, result.result);
    });
  });
}
function(argv, context, callback) {
  return MongoClient.connect(mongoHost, function(err, db) {
    if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); }

    var partnersDb  = db.collection('partners');
    var partnerId   = argvGet(argv, 'partner-id,partner');

    var item = {};

    _.each(argv, (value, key) => {
      sg.setOnn(item, ['$set', sg.toCamelCase(key)], sg.smartValue(value));
    });

    everbose(2, `Upserting partner: ${partnerId}`);
    return partnersDb.updateOne({partnerId}, item, {upsert:true}, function(err, result) {
      if (err)  { console.error(err); }

      db.close();
      return callback(err, result.result);
    });
  });
}
function ( argv , context , callback ) { return MongoClient . connect ( mongoHost , function ( err , db ) { if ( err ) { return sg . die ( err , callback , 'upsertPartner.MongoClient.connect' ) ; } var partnersDb = db . collection ( 'partners' ) ; var partnerId = argvGet ( argv , 'partner-id,partner' ) ; var item = { } ; _ . each ( argv , ( value , key ) => { sg . setOnn ( item , [ '$set' , sg . toCamelCase ( key ) ] , sg . smartValue ( value ) ) ; } ) ; everbose ( 2 , ` ${ partnerId } ` ) ; return partnersDb . updateOne ( { partnerId } , item , { upsert : true } , function ( err , result ) { if ( err ) { console . error ( err ) ; } db . close ( ) ; return callback ( err , result . result ) ; } ) ; } ) ; }
Just insert one partner without any intelligence on inserting a project
Just insert one partner without any intelligence on inserting a project