How to use the @sanity/import function in @sanity/import

To help you get started, we’ve selected a few @sanity/import 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 sanity-io / sanity / packages / @sanity / core / src / commands / dataset / importDatasetCommand.js View on Github external
spinInterval = null

      if (success) {
        const timeSpent = prettyMs(Date.now() - stepStart, {
          secDecimalDigits: 2
        })
        currentProgress.text = `[100%] ${currentStep} (${timeSpent})`
        currentProgress.succeed()
      } else if (currentProgress) {
        currentProgress.fail()
      }
    }

    // Start the import!
    try {
      const {numDocs, warnings} = await sanityImport(inputStream, {
        client: importClient,
        operation,
        onProgress,
        allowFailingAssets
      })

      endTask({success: true})

      output.print('Done! Imported %d documents to dataset "%s"\n', numDocs, targetDataset)
      printWarnings(warnings, output)
    } catch (err) {
      endTask({success: false})

      let error = err.message
      if (!fromInitCommand && err.response && err.response.statusCode === 409) {
        error = [

@sanity/import

Import documents to a Sanity dataset

MIT
Latest version published 11 days ago

Package Health Score

81 / 100
Full package analysis

Popular @sanity/import functions