UNPKG

@cocalc/database

Version:

CoCalc: code for working with our PostgreSQL database

22 lines 653 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toEpoch = void 0; /* Some random little utils */ const misc_1 = require("@cocalc/util/misc"); // Convert timestamp fields as returned from postgresql queries // into ms since the epoch, as a number. function toEpoch(rows, fields) { if (!(0, misc_1.is_array)(rows)) { rows = [rows]; } // @ts-ignore for (const row of rows) { for (const field of fields) { if (row[field]) { row[field] = new Date(row[field]).valueOf(); } } } } exports.toEpoch = toEpoch; //# sourceMappingURL=util.js.map