文件操作 - postgresql.mjs
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/db0/connectors/postgresql.mjs
编辑文件内容
import pg from "pg"; export default function postgresqlConnector(opts) { let _client; function getClient() { if (_client) { return _client; } const client = new pg.Client("url" in opts ? opts.url : opts); _client = client.connect().then(() => { _client = client; return _client; }); return _client; } async function query(sql, params) { const client = await getClient(); return client.query(normalizeParams(sql), params); } return { name: "postgresql", dialect: "postgresql", getInstance: () => getClient(), exec(sql) { return query(sql); }, prepare(sql) { const stmt = { _sql: sql, _params: [], bind(...params) { if (params.length > 0) { this._params = params; } return stmt; }, all(...params) { return query(this._sql, params || this._params).then((r) => r.rows); }, run(...params) { return query(this._sql, params || this._params).then((r) => ({ result: r, rows: r.rows })); }, get(...params) { return query(this._sql, params || this._params).then( (r) => r.rows[0] ); } }; return stmt; } }; } function normalizeParams(sql) { let i = 0; return sql.replace(/\?/g, () => `$${++i}`); }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件