- Fixed imports in examples/tests/ to use correct Brainy import - Fixed imports in tests/benchmarks/ to use correct paths - Updated bin/brainy-interactive.js to use Brainy instead of BrainyData - Corrected documentation references throughout codebase - Removed duplicate imports in benchmark files - All files now consistently use 'Brainy' class from dist/index.js
32 lines
No EOL
977 B
JavaScript
32 lines
No EOL
977 B
JavaScript
#!/usr/bin/env node
|
|
|
|
import { Brainy } from './dist/index.js'
|
|
|
|
const brain = new Brainy({
|
|
storage: { type: 'memory' },
|
|
verbose: false
|
|
})
|
|
|
|
await brain.init()
|
|
|
|
console.log('Test updateNoun metadata merging:')
|
|
|
|
// Add with object as data (auto-detects as metadata)
|
|
const id = await brain.addNoun({ name: 'TypeScript', version: '4.0' })
|
|
console.log('1. Added:', id)
|
|
|
|
// Get to verify initial state
|
|
const initial = await brain.getNoun(id)
|
|
console.log('2. Initial metadata:', initial?.metadata)
|
|
|
|
// Update with new metadata (should merge)
|
|
await brain.updateNoun(id, { version: '5.0', popularity: 'high' })
|
|
|
|
// Get to verify merge
|
|
const updated = await brain.getNoun(id)
|
|
console.log('3. Updated metadata:', updated?.metadata)
|
|
console.log(' - version:', updated?.metadata?.version, '(expected: 5.0)')
|
|
console.log(' - popularity:', updated?.metadata?.popularity, '(expected: high)')
|
|
console.log(' - name:', updated?.metadata?.name, '(expected: TypeScript)')
|
|
|
|
process.exit(0) |