This commit is contained in:
seb
2026-08-07 05:21:56 +02:00
parent 70e0a9ddc4
commit 396389457f
22 changed files with 225 additions and 242 deletions

View File

@@ -1,18 +1,18 @@
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) {
/**
* Returns a language row by its ISO 639 code.
*
* @param {string} iso639 - The ISO 639 language code (e.g. `'de'`).
* @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<{id: number, iso639: string}>} The language row, or `undefined` if not found.
*
* @example
* const lang = await store.lang.getByIso639('de');
* // => { id: 1, iso639: 'de' }
*/
return async (iso639, tx) => {
const result = await request(pool, tx)
.input('iso639', iso639)