docs: add JSDoc headers to all externally exported store functions
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import { CREATE } from '../../sql/tax.js';
|
||||
import request from '../request.js';
|
||||
|
||||
/**
|
||||
* Creates a new tax rate.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that creates a tax rate.
|
||||
*
|
||||
* @example
|
||||
* const fn = create(pool);
|
||||
* const id = await fn(19);
|
||||
* // => 1
|
||||
*/
|
||||
export default function create(pool) {
|
||||
return async (rate, tx) => {
|
||||
const result = await request(pool, tx)
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import getByRate from './getByRate.js';
|
||||
import create from './create.js';
|
||||
|
||||
/**
|
||||
* Returns the id of a tax rate, creating it if it does not exist.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that ensures a tax rate exists.
|
||||
*
|
||||
* @example
|
||||
* const fn = ensure(pool);
|
||||
* const id = await fn(19);
|
||||
* // => 1
|
||||
*/
|
||||
export default function ensure(pool) {
|
||||
const get = getByRate(pool);
|
||||
const add = create(pool);
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import { GET_BY_RATE } from '../../sql/tax.js';
|
||||
import request from '../request.js';
|
||||
|
||||
/**
|
||||
* Returns a tax row by its rate.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that fetches a tax rate.
|
||||
*
|
||||
* @example
|
||||
* const fn = getByRate(pool);
|
||||
* const tax = await fn(19);
|
||||
* // => { id, rate }
|
||||
*/
|
||||
export default function getByRate(pool) {
|
||||
return async (rate, tx) => {
|
||||
const result = await request(pool, tx)
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { LIST } from '../../sql/tax.js';
|
||||
|
||||
/**
|
||||
* Lists all tax rates.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that lists tax rates.
|
||||
*
|
||||
* @example
|
||||
* const fn = list(pool);
|
||||
* const taxes = await fn();
|
||||
* // => [{ id, rate }]
|
||||
*/
|
||||
export default function list(pool) {
|
||||
return async () => {
|
||||
const result = await pool.request().query(LIST);
|
||||
|
||||
Reference in New Issue
Block a user