UNPKG

@magda/scripts

Version:

Scripts for building, running, and deploying MAGDA

14 lines (13 loc) 465 B
import isUuid from "@magda/typescript-common/dist/util/isUuid.js"; async function getNodeIdByNameOrId(nameOrId, queryer) { if (isUuid(nameOrId)) { return nameOrId; } else { const nodes = await queryer.getNodes({ name: nameOrId }, ["id"]); if (!nodes || !nodes.length) { throw new Error(`Cannot locate node record with name: ${nameOrId}`); } return nodes[0].id; } } export default getNodeIdByNameOrId;