0.1.1 • Published 9 months ago
btsql.js v0.1.1
btSQL
btSQL is a decentralized SQL database on BTFS (BitTorrent File System).
btsql.js allows you to interact with btSQL using your api keys
Installation
npm install btsql.js
Usage
import BTSQLClient from 'btsql.js';
const apiKey = 'your-api-key';
const walletAddress = 'your-wallet-address';
const client = new BTSQLClient(apiKey, walletAddress);
// Create a database
await client.createDatabase('myDatabase');
// List databases
const databases = await client.listDatabases();
console.log(databases);
// List tables in a database
const tables = await client.listTables('myDatabase');
console.log(tables);
// Execute a query
const query = 'SELECT FROM users WHERE age > 18';
const results = await client.executeQuery('myDatabase', query);
console.log(results);
API Reference
new BTSQLClient(apiKey: string, walletAddress: string, apiUrl?: string)
Creates a new BTSQLClient instance.
createDatabase(name: string): Promise<void>
Creates a new database with the specified name.
listDatabases(): Promise<string[]>
Returns an array of database names.
listTables(database: string): Promise<string[]>
Returns an array of table names in the specified database.
executeQuery(database: string, query: string): Promise<any>
Executes an SQL query on the specified database and returns the results.