function doUpdateDatasetClient(datasetClientId, fields, upsert, cb) {
  debug('doUpdateDatasetClient datasetClientId = %s :: fields = %j', datasetClientId, fields);
  var col = mongoClient.collection(DATASETCLIENTS_COLLECTION);
  delete fields._id;
  col.findOneAndUpdate({id: datasetClientId}, {'$set': fields}, {upsert: upsert, returnOriginal: false}, function(err, result) {
    if (err) {
      debugError('Failed to update datasetClients due to error %s :: datasetClientId = %s :: fields = %j',err,datasetClientId,fields);
      return cb(err);
    }

    if (result.value === null) {
      return cb(new Error('DatasetClient not found for id ' + datasetClientId));
    }

    //ensure the indexes are create for a given dataset
    ensureIndexesForDataset(result.value.datasetId);
    return cb(null, result.value);
  });
}
function doUpdateDatasetClient(datasetClientId, fields, upsert, cb) {
  debug('doUpdateDatasetClient datasetClientId = %s :: fields = %j', datasetClientId, fields);
  var col = mongoClient.collection(DATASETCLIENTS_COLLECTION);
  delete fields._id;
  col.findOneAndUpdate({id: datasetClientId}, {'$set': fields}, {upsert: upsert, returnOriginal: false}, function(err, result) {
    if (err) {
      debugError('Failed to update datasetClients due to error %s :: datasetClientId = %s :: fields = %j',err,datasetClientId,fields);
      return cb(err);
    }

    if (result.value === null) {
      return cb(new Error('DatasetClient not found for id ' + datasetClientId));
    }

    
    ensureIndexesForDataset(result.value.datasetId);
    return cb(null, result.value);
  });
}
function doUpdateDatasetClient ( datasetClientId , fields , upsert , cb ) { debug ( 'doUpdateDatasetClient datasetClientId = %s :: fields = %j' , datasetClientId , fields ) ; var col = mongoClient . collection ( DATASETCLIENTS_COLLECTION ) ; delete fields . _id ; col . findOneAndUpdate ( { id : datasetClientId } , { '$set' : fields } , { upsert : upsert , returnOriginal : false } , function ( err , result ) { if ( err ) { debugError ( 'Failed to update datasetClients due to error %s :: datasetClientId = %s :: fields = %j' , err , datasetClientId , fields ) ; return cb ( err ) ; } if ( result . value === null ) { return cb ( new Error ( 'DatasetClient not found for id ' + datasetClientId ) ) ; } //ensure the indexes are create for a given dataset ensureIndexesForDataset ( result . value . datasetId ) ; return cb ( null , result . value ) ; } ) ; }
Update the dataset client
@param {String} datasetClientId the datasetClient id
@param {storage~DatasetClient} fields the fields that need to be updated
@param {Boolean} upsert if true, the record will be created if can't be found
@param {Function} cb
Update the dataset client