UNPKG

@cocalc/server

Version:

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

30 lines (28 loc) 1.09 kB
"use strict"; /* Set the checked state in the database for an item in the shopping cart. If id is not set, sets checked state for all items in shopping cart. Returns number of modified items. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const misc_1 = require("@cocalc/util/misc"); const pool_1 = __importDefault(require("@cocalc/database/pool")); async function setCheck(account_id, checked, id) { if (!(0, misc_1.isValidUUID)(account_id)) { throw Error("account_id is invalid"); } const pool = (0, pool_1.default)(); let query = "UPDATE shopping_cart_items SET checked=$1 WHERE account_id=$2 AND removed IS NULL AND purchased IS NULL"; const params = [checked, account_id]; if (id != null) { query += " AND id=$3 "; params.push(id); } const { rowCount } = await pool.query(query, params); return rowCount; } exports.default = setCheck; //# sourceMappingURL=checked.js.map