Config
config/google-mysql.js
const prod = process.env.NODE_ENV === "production";
const AppDataSource = new DataSource({
type: "mysql",
host: "127.0.0.1",
port: 3306,
// username: process.env.googleSQLUsername,
// password: process.env.googleSQLPassword,
username: "root",
password: process.env.SQLPASSWORD,
database: "development",
entities: [ block_transaction, contract, tokens, transaction_hash, wallet_address, ],
synchronize: true,
logging: false,
// Production Mode
...(prod && {
database: "production",
logging: false, // synchronize: false,
extra: { socketPath: "/cloudsql/<YOUR_CONNECTION_INSTANCE_HERE>", // change
}, }), });
const mysql = AppDataSource.initialize();
module.exports = mysql;
app.js
const mysql = require("../config/google-mysql");
const connection = await mysql;
let results = await connection
.getRepository("block_transaction")
.createQueryBuilder("block_transaction")
.select(
"DISTINCT from_address as address,sum(value) as value,sum(amount) as amount,count(from_address) as count"
)
.where("createdAt > :createTime1", {
createTime1: subtractDate(10),
})
.andWhere("from_address != :address", {
address: "0x0000000000000000000000000000000000000000",
})
.groupBy("from_address")
.orderBy("count(from_address)", "DESC")
// .limit(100)
.getRawMany();
console.log(results)
try{
}catch(error){
console.log(error.message,'here is the error')
Last updated
Was this helpful?