geolite
Version:
A lightweight geo data toolkit with countries, states, cities, timezones, currencies, and dialing codes. Works with Prisma and SQLite.
3 lines (2 loc) • 1.18 kB
JavaScript
"use server";var o=Object.defineProperty;var t=(e,r)=>o(e,"name",{value:r,configurable:!0});import i from"../utils/prisma.js";async function a(){return await i.dialingCode.findMany({select:{code:!0,root:!0,suffix:!0,example:!0},orderBy:{code:"asc"}})}t(a,"getAllDialingCodes");async function d(e){return e?await i.dialingCode.findUnique({where:{code:e},select:{code:!0,root:!0,suffix:!0,example:!0,country:{select:{code:!0,name:!0}},states:{select:{id:!0,name:!0}}}}):null}t(d,"getDialingCodeByCode");async function l(e){return e?await i.dialingCode.findMany({where:{countryCode:e},select:{code:!0,root:!0,suffix:!0,example:!0},orderBy:{code:"asc"}}):[]}t(l,"getDialingCodesOfCountry");async function s(e){if(!e)return null;const r=await i.state.findUnique({where:{id:e},select:{dialingCode:{select:{code:!0,root:!0,suffix:!0,example:!0}},country:{select:{phoneCodes:{select:{code:!0,root:!0,suffix:!0,example:!0},orderBy:{code:"asc"}}}}}});return r?.dialingCode||r?.country?.phoneCodes?.[0]||null}t(s,"getDialingCodeOfState");export{a as getAllDialingCodes,d as getDialingCodeByCode,s as getDialingCodeOfState,l as getDialingCodesOfCountry};
//# sourceMappingURL=dialing-code.js.map