How to use the webiny-entity.Entity.getDriver function in webiny-entity

To help you get started, we’ve selected a few webiny-entity 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 webiny / webiny-js / packages / webiny-api / src / lambda / lambda.js View on Github external
const requestSetup = async (config: Object = {}) => {
    // Configure Entity layer
    if (config.entity) {
        Entity.driver = config.entity.driver;
        Entity.crud = config.entity.crud;
    }

    // Check if connection is valid and if Settings table exists - this will tell us if the system is installed.
    if (process.env.NODE_ENV === "development") {
        try {
            await Entity.getDriver().test();
        } catch (e) {
            throw Error(
                `The following error occurred while initializing Entity driver: "${
                    e.message
                }". Did you enter the correct database information?`
            );
        }
    }
};