docs: add JSDoc headers to all externally exported store functions

This commit is contained in:
seb
2026-08-07 03:58:48 +02:00
parent c290fe8f4b
commit 4833acd680
101 changed files with 1134 additions and 0 deletions

View File

@@ -1,6 +1,17 @@
import { CREATE } from '../../sql/language.js';
import request from '../request.js';
/**
* Creates a new language by its ISO 639 code.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that creates a language.
*
* @example
* const fn = create(pool);
* const id = await fn('de');
* // => 1
*/
export default function create(pool) {
return async (iso639, tx) => {
const result = await request(pool, tx)

View File

@@ -1,5 +1,15 @@
import { DELETE } from '../../sql/language.js';
/**
* Deletes a language by its id.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that deletes a language.
*
* @example
* const fn = del(pool);
* await fn(1);
*/
export default function del(pool) {
return async (id) => {
await pool

View File

@@ -1,6 +1,17 @@
import getByIso639 from './getByIso639.js';
import create from './create.js';
/**
* Returns the id of a language by ISO code, creating it if it does not exist.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that ensures a language exists.
*
* @example
* const fn = ensure(pool);
* const id = await fn('de');
* // => 1
*/
export default function ensure(pool) {
const get = getByIso639(pool);
const add = create(pool);

View File

@@ -1,6 +1,17 @@
import { GET_BY_ISO639 } from '../../sql/language.js';
import request from '../request.js';
/**
* Returns a language row by its ISO 639 code.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that fetches a language by ISO code.
*
* @example
* const fn = getByIso639(pool);
* const lang = await fn('de');
* // => { id, iso639 }
*/
export default function getByIso639(pool) {
return async (iso639, tx) => {
const result = await request(pool, tx)

View File

@@ -1,5 +1,16 @@
import { LIST } from '../../sql/language.js';
/**
* Lists all languages.
*
* @param {object} pool - The mssql connection pool.
* @returns {Function} An async function that lists languages.
*
* @example
* const fn = list(pool);
* const languages = await fn();
* // => [{ id, iso639 }]
*/
export default function list(pool) {
return async () => {
const result = await pool.request().query(LIST);