@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 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