How to use the @cumulus/cmrjs.searchConcept function in @cumulus/cmrjs

To help you get started, we’ve selected a few @cumulus/cmrjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nasa / cumulus / packages / api / lib / injectConceptId.js View on Github external
const updateRecordWithConceptId = async (collectionRecord) => {
  let updatedCollectionRecord = cloneDeep(collectionRecord);
  const searchParams = {
    short_name: collectionRecord.name || '',
    version: collectionRecord.version || '',
    provider_short_name: process.env.cmr_provider
  };

  const cmrResult = await cmrjs.searchConcept('collections', searchParams, []);

  let conceptId = null;
  if (cmrResult.length === 1) conceptId = cmrResult[0].id;
  updatedCollectionRecord = Object.assign(collectionRecord, { conceptId: conceptId });
  return updatedCollectionRecord;
};