"use strict";
// Get the name of an owner, i.e., an account_id or organization_id.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pool_1 = __importDefault(require("@cocalc/database/pool"));
// Returns "" if owner doesn't have a name set.
async function getName(owner_id) {
    const pool = (0, pool_1.default)('medium');
    for (const type of ["account", "organization"]) {
        const result = await pool.query(`SELECT name FROM ${type}s WHERE ${type}_id=$1`, [owner_id]);
        if (result.rows.length > 0) {
            return result.rows[0].name;
        }
    }
    return "";
}
exports.default = getName;
//# sourceMappingURL=get-name.js.map