import { createClient } from '@onchaindb/sdk';
const client = createClient({
endpoint: 'https://api.onchaindb.io',
appId: 'my-app',
appKey: 'your-app-key'
});
// Create
const user = await client.createDocument(
'users',
{ email: 'alice@example.com', name: 'Alice', active: true },
paymentProof
);
console.log('Created:', user.id);
// Read
const found = await client.findUnique('users', { email: 'alice@example.com' });
console.log('Found:', found?.name);
// Update
const updated = await client.updateDocument(
'users',
{ email: 'alice@example.com' },
{ name: 'Alice Smith' },
paymentProof
);
console.log('Updated:', updated?.name);
// Delete
const deleted = await client.deleteDocument(
'users',
{ email: 'alice@example.com' },
paymentProof
);
console.log('Deleted:', deleted);