UNPKG

defarm-sdk

Version:

DeFarm SDK - On-premise blockchain data processing and tokenization engine for agriculture supply chain

64 lines (53 loc) 1.45 kB
// Mock adapters for testing without external dependencies class MockDatabaseAdapter { constructor(config) { this.config = config; this.connected = false; } async connect() { console.log(`📋 Mock ${this.constructor.name} connected to ${this.config.host}`); this.connected = true; } async disconnect() { this.connected = false; } async query(sql, params = []) { console.log(`🔍 Mock query: ${sql.substring(0, 50)}...`); return []; } async execute(sql) { console.log(`⚡ Mock execute: ${sql.substring(0, 50)}...`); return { affectedRows: 1 }; } async insert(table, data) { console.log(`➕ Mock insert into ${table}`); return { id: Math.floor(Math.random() * 10000) }; } async update(table, data, where) { console.log(`✏️ Mock update ${table}`); return { affectedRows: 1 }; } } class PostgreSQLAdapter extends MockDatabaseAdapter { constructor(config) { super(config); console.log('🐘 PostgreSQL adapter initialized (mock)'); } } class OracleAdapter extends MockDatabaseAdapter { constructor(config) { super(config); console.log('🏛️ Oracle adapter initialized (mock)'); } } class SQLServerAdapter extends MockDatabaseAdapter { constructor(config) { super(config); console.log('🪟 SQL Server adapter initialized (mock)'); } } module.exports = { PostgreSQLAdapter, OracleAdapter, SQLServerAdapter };