UNPKG

@cocalc/server

Version:

CoCalc server functionality: functions used by either the hub and the next.js server

26 lines (25 loc) 1.14 kB
"use strict"; /* get up to limit projects that have the given user as a collaborator, ordered by how recently they were modified. DELETED and HIDDEN projects are skipped. */ 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")); const misc_1 = require("@cocalc/util/misc"); // I may add more fields and more options later... async function getProjects({ account_id, limit = 50, }) { if (!(0, misc_1.is_valid_uuid_string)(account_id)) { throw Error("account_id must be a UUIDv4"); } if (limit <= 0) { return []; } const pool = (0, pool_1.default)(); const { rows } = await pool.query(`SELECT project_id, title, description FROM projects WHERE DELETED IS NOT true AND users ? $1 AND (users#>>'{${account_id},hide}')::BOOLEAN IS NOT TRUE ORDER BY last_edited DESC LIMIT $2`, [account_id, limit]); return rows; } exports.default = getProjects; //# sourceMappingURL=get.js.map