All files / src/modules/implementations/queries/support database-valuation-commodity.js

100% Statements 12/12
100% Branches 5/5
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 1351x 51x 51x 783x 454x 454x 2x 2x 452x 454x 783x 51x  
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = ({ core: { publicErrors: { createError, errorCodes }, }, }) => {
    function valuationCommodityFromDatabase(database) {
        const valuationCommodity = database.prepare("SELECT value FROM database_metadata WHERE key = 'valuation_commodity'").pluck().get();
        if (!valuationCommodity) {
            throw createError(errorCodes.MISSING_VALUATION_DATA, 'The journal does not declare a default commodity for valuation');
        }
        return valuationCommodity;
    }
    return { valuationCommodityFromDatabase };
};