Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@truffle/db-loader

trufflesuite36.7kMITdeprecated0.2.36TypeScript support: included

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

Utility for loading @truffle/db

ethereum, Truffle, Truffle Db

readme

@truffle/db-loader

A loader for importing Truffle Db that does not throw an error when it is not installed.

Contents

This package's main export is a method called getTruffleDb. To import it, simply destructure it from the package.

const { getTruffleDb } = require("@truffle/db-loader");

When you call the method, it will return an instance of Truffle Db or null if the import fails.

const Db = getTruffleDb();
if (Db === null) {
  throw new Error("There was an error importing Truffle Db.");
}

Note that you will need to do a check for a null value if you want to provide handling for the case where Truffle Db fails to load.

Please see the README for @truffle/db for more information on using Truffle Db.