
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
High-performance, ACID-compliant embedded database with WAL optimization, MVCC, and vector search capabilities
BMDB is a high-performance, ACID-compliant embedded database for Node.js and Bun, featuring optimized Write-Ahead Logging (WAL), MVCC transactions, and vector search capabilities.
npm install bmdb
yarn add bmdb
pnpm add bmdb
bun add bmdb
import { TinyDB, JSONStorage } from 'bmdb';
// Create database with JSON storage
const db = new TinyDB('db.json', JSONStorage);
// Insert documents
const users = db.table('users');
const userId = users.insert({ name: 'Alice', age: 30, email: 'alice@example.com' });
// Query documents
const user = users.get(userId);
const adults = users.search({ age: { $gte: 18 } });
import { TinyDB, WALJSONStorage } from 'bmdb';
// Use optimized WAL storage for high-throughput applications
const db = new TinyDB('db.json', WALJSONStorage, {
batchSize: 1000, // Batch up to 1000 operations
maxBatchWaitMs: 20 // Maximum 20ms wait for batching
});
// Perform high-throughput writes
const table = db.table('events');
for (let i = 0; i < 10000; i++) {
table.insert({
timestamp: Date.now(),
event: `event_${i}`,
data: { value: i }
});
}
import { TinyDB, createSchema, field, unique } from 'bmdb';
import { z } from 'zod';
// Define schema with validation
const userSchema = createSchema({
name: field(z.string().min(1).max(100)),
email: field(z.string().email()).unique(),
age: field(z.number().int().min(0).max(150))
});
const db = new TinyDB('users.json');
const users = db.schemaTable('users', userSchema);
// Type-safe operations with validation
const user = users.insert({
name: 'Bob',
email: 'bob@example.com',
age: 25
}); // TypeScript knows the shape and validates uniqueness
import { TinyDB, MemoryStorage } from 'bmdb';
const db = new TinyDB(MemoryStorage);
const embeddings = db.table('embeddings');
// Insert vectors
embeddings.insert({
text: 'Hello world',
vector: [0.1, 0.2, 0.3, 0.4]
});
embeddings.insert({
text: 'Machine learning',
vector: [0.2, 0.3, 0.4, 0.5]
});
// Search similar vectors
const query = [0.15, 0.25, 0.35, 0.45];
const similar = embeddings.vectorSearch('vector', query, { limit: 5 });
import { TinyDB, WALStorage } from 'bmdb';
const db = new TinyDB('transactional.db', WALStorage);
// Use transactions for atomic operations
const txid = db.storage.beginTransaction();
try {
db.storage.writeInTransaction(txid, {
accounts: {
alice: { balance: 950 },
bob: { balance: 1050 }
}
});
db.storage.commitTransaction(txid);
} catch (error) {
db.storage.abortTransaction(txid);
throw error;
}
import { TinyDB, JSONStorage } from 'bmdb';
const db = new TinyDB('data.json', JSONStorage);
import { TinyDB, WALJSONStorage } from 'bmdb';
const db = new TinyDB('data.json', WALJSONStorage, {
batchSize: 1000,
maxBatchWaitMs: 20
});
import { TinyDB, BinaryStorage } from 'bmdb';
const db = new TinyDB('data.msgpack', BinaryStorage);
import { TinyDB, MemoryStorage } from 'bmdb';
const db = new TinyDB(MemoryStorage);
const users = db.table('users');
// Find by field value
users.search({ name: 'Alice' });
// Complex conditions
users.search({
age: { $gte: 18, $lt: 65 },
status: 'active'
});
// Using query builder
import { where } from 'bmdb';
users.search(where('age').gte(18).and(where('status').equals('active')));
// Regular expressions
users.search({ email: { $regex: /@company\.com$/ } });
// Array operations
users.search({ tags: { $contains: 'premium' } });
// Nested objects
users.search({ 'profile.settings.notifications': true });
BMDB includes several performance optimizations:
const db = new TinyDB('data.json', WALJSONStorage, {
batchSize: 1000, // Operations per batch
maxBatchWaitMs: 20, // Maximum batch wait time
compactThreshold: 5000, // WAL size trigger for compaction
autoFlushMs: 100, // Auto-flush interval
backgroundCompaction: true, // Enable background compaction
useMsgPack: false // Use MessagePack for WAL entries
});
import { field, unique, primaryKey, compoundIndex } from 'bmdb';
const schema = createSchema({
id: field(z.string()).primaryKey(),
email: field(z.string().email()).unique(),
name: field(z.string()),
createdAt: field(z.date())
}, {
// Compound indexes for efficient queries
compoundIndexes: [
compoundIndex(['name', 'createdAt'])
]
});
Performance comparison on write-heavy workloads:
Storage Engine | Throughput (ops/sec) | Latency (ms) | Memory Usage |
---|---|---|---|
WALJSONStorage | 50,000+ | <1ms | Low |
JSONStorage | 500 | 20ms | Medium |
BinaryStorage | 15,000 | 2ms | Low |
MemoryStorage | 100,000+ | <0.1ms | High |
# Run tests
bun test
# Run performance benchmarks
bun run test/performance-comparison.ts
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
MIT License - see LICENSE file for details.
Made with ❤️ for high-performance applications
FAQs
High-performance, ACID-compliant embedded database with WAL optimization, MVCC, and vector search capabilities
We found that bmdb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.