'use strict';

const path = require('path');
const FileBackend = require('../backends/FileBackend');

// unitData.json lives at datasets/ (not datasets/assetData/).
const backend = new FileBackend({
    baseDir: path.resolve(__dirname, '../../../datasets'),
    layout: 'single-file',
    filePath: 'unitData.json',
    arrayKey: 'units',
    indexField: 'category',
    caseInsensitive: true,
});

module.exports = {
    name: 'units',
    description: 'Unit families keyed by measurement category (flow, pressure, …)',
    loadAll: () => backend.loadAll(),
    refresh: () => backend.refresh(),
};
