29 lines
965 B
TypeScript
29 lines
965 B
TypeScript
import { createClient } from '@supabase/supabase-js';
|
|
import * as dotenv from 'dotenv';
|
|
import path from 'path';
|
|
|
|
dotenv.config({ path: path.resolve(process.cwd(), '.env') });
|
|
const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!);
|
|
|
|
async function dumpTable(table: string) {
|
|
console.log(`\n--- ${table} ---`);
|
|
const { data, error } = await supabase.from(table).select('*').order('created_at', { ascending: false }).limit(5);
|
|
if (error) console.error(error);
|
|
else console.log(JSON.stringify(data, null, 2));
|
|
}
|
|
|
|
async function listUsers() {
|
|
console.log('\n--- Users ---');
|
|
const { data, error } = await supabase.from('users').select('user_id, email, trade_enable');
|
|
if (error) console.error(error);
|
|
else console.log(JSON.stringify(data, null, 2));
|
|
}
|
|
|
|
async function main() {
|
|
await listUsers();
|
|
await dumpTable('orders');
|
|
await dumpTable('trade_history');
|
|
}
|
|
|
|
main();
|