docs: add JSDoc headers to all externally exported store functions
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
import { DELETE_BY_COMPANY_AND_SI } from '../../sql/unit.js';
|
||||
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
|
||||
/**
|
||||
* Deletes a unit for a company by its SI code.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that deletes a unit.
|
||||
*
|
||||
* @example
|
||||
* const fn = del(pool);
|
||||
* await fn(42, 1, 'l');
|
||||
*/
|
||||
export default function del(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
|
||||
|
||||
@@ -2,6 +2,17 @@ import { LIST_BY_COMPANY } from '../../sql/unit.js';
|
||||
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
import shapeUnit from './shapeUnit.js';
|
||||
|
||||
/**
|
||||
* Lists the units available for a company.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that lists units.
|
||||
*
|
||||
* @example
|
||||
* const fn = list(pool);
|
||||
* const units = await fn(42, 1);
|
||||
* // => [{ id, si, basesi, basesifactor, symbol, name }]
|
||||
*/
|
||||
export default function list(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
|
||||
|
||||
@@ -30,6 +30,17 @@ function validateUnit({ si, basesi, basesifactor, symbol, name }) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates or updates a unit for a company, keyed by its SI code.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that upserts a unit.
|
||||
*
|
||||
* @example
|
||||
* const fn = upsert(pool);
|
||||
* const unit = await fn(42, 1, { si: 'l', basesi: 'm3', basesifactor: 0.001, symbol: 'L', name: 'Liter' });
|
||||
* // => { id, si, basesi, basesifactor, symbol, name }
|
||||
*/
|
||||
export default function upsert(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user