123456789101112131415161718192021222324252627282930313233343536 |
- const pgp = require('pg-promise')();
- // 连接到数据库
- const db = pgp({
- user: 'web3',
- password: '666',
- host: 'web2023.fmode.cn',
- port: 25432,
- database: 'dev'
- });
- // 执行SELECT语句并返回结果的函数
- async function main() {
- try {
- // 查询:Member数量查询
- const data1 = await db.any(`SELECT COUNT(1) FROM "Member";`);
- console.log(`Member数量:`,data1)
- // 查询:InviteEvent数量查询
- const data2 = await db.any(`SELECT COUNT(1) FROM "InviteEvent";`);
- console.log(`InviteEvent数量:`,data2)
- // 查询:邀请关系会员列表查询
- let inviteId = "1"
- const data3 = await db.any(`SELECT * FROM "Member" WHERE ("invitePath" ?& $1 OR "invite"=$2)`,[[inviteId],inviteId]);
- console.log(`邀请关系会员列表:`,data3)
- return true;
- } catch (error) {
- console.error('Error executing SELECT query:', error);
- return null;
- }
- }
- // 调用函数并处理结果
- main()
|