@soulcraft/brainy 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/brainy.js +2400 -2749
- package/dist/brainy.min.js +747 -747
- package/dist/brainyData.d.ts +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/unified.js +55 -7
- package/dist/unified.min.js +747 -747
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/statistics.d.ts +18 -0
- package/dist/utils/statistics.d.ts.map +1 -0
- package/dist/utils/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/utils/logger.d.ts +0 -99
- package/dist/utils/logger.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -488,6 +488,32 @@ const backupData = await db.backup()
|
|
|
488
488
|
const restoreResult = await db.restore(backupData, {clearExisting: true})
|
|
489
489
|
```
|
|
490
490
|
|
|
491
|
+
### Database Statistics
|
|
492
|
+
|
|
493
|
+
Brainy provides a way to get statistics about the current state of the database:
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
import { BrainyData, getStatistics } from '@soulcraft/brainy'
|
|
497
|
+
|
|
498
|
+
// Create and initialize the database
|
|
499
|
+
const db = new BrainyData()
|
|
500
|
+
await db.init()
|
|
501
|
+
|
|
502
|
+
// Get statistics using the standalone function
|
|
503
|
+
const stats = await getStatistics(db)
|
|
504
|
+
console.log(stats)
|
|
505
|
+
// Output: { nounCount: 0, verbCount: 0, metadataCount: 0, hnswIndexSize: 0 }
|
|
506
|
+
|
|
507
|
+
// Or using the instance method
|
|
508
|
+
const instanceStats = await db.getStatistics()
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
The statistics include:
|
|
512
|
+
- `nounCount`: Number of nouns (entities) in the database
|
|
513
|
+
- `verbCount`: Number of verbs (relationships) in the database
|
|
514
|
+
- `metadataCount`: Number of metadata entries
|
|
515
|
+
- `hnswIndexSize`: Size of the HNSW index
|
|
516
|
+
|
|
491
517
|
### Working with Nouns (Entities)
|
|
492
518
|
|
|
493
519
|
```typescript
|