nl_tokens: Remove the datasetClient that matches the given datasetClientId and also remove the references of the datasetClient from the records .
pl_tokens: function doRemoveDatasetClientWithRecords ( datasetClientId , cb ) { <mask> ( 'doRemoveDatasetClientWithRecords datasetClientId = %s' , datasetClientId ) ; async . waterfall ( [ async . apply ( doReadDatasetClient , datasetClientId ) , function removeRefs ( datasetClientJson , next ) { var datasetId = datasetClientJson . datasetId ; var recordsCollection = mongoClient . collection ( getDatasetRecordsCollectionName ( datasetId ) ) ; recordsCollection . updateMany ( { 'refs' : datasetClientId } , { '$pull' : { 'refs' : datasetClientId } } , function ( err ) { return next ( err , datasetClientJson ) ; } ) ; } , function deleteDatasetClient ( datasetClientJson , next ) { var col = mongoClient . collection ( DATASETCLIENTS_COLLECTION ) ; col . findOneAndDelete ( { 'id' : datasetClientId } , next ) ; } ] , function ( err , result ) { if ( err ) { debug ( 'Failed to doRemoveDatasetClientWithRecords due to error %s' , err ) ; return cb ( err ) ; } else { return cb ( null , result && result . value ) ; } } ) ; }