// src/VectorStore.ts>OramaStore
async restore(vectorStoreBackup: VectorStoreBackup) {
Log.debug('Restoring vectorstore from backup');
// vectorStoreBackup is an object and not an array for some reason
const docs = Object.keys(vectorStoreBackup.docs).map((key) => vectorStoreBackup.docs[key]);
await this.create(vectorStoreBackup.indexName, vectorStoreBackup.vectorSize);
await insertMultiple(this.db, docs);// plugin:smart-second-brain:30 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'length')
Log.info('Restored vectorstore from backup');
Log.debug(this.db.data.docs.docs);
}
Can I fix the error like this?
async restore(vectorStoreBackup: VectorStoreBackup) {
Log.debug('Restoring vectorstore from backup');
const docs = Object.keys(vectorStoreBackup.docs).map((key) => vectorStoreBackup.docs[key]);
await this.create(vectorStoreBackup.indexName, vectorStoreBackup.vectorSize);
if (docs.length > 0) {
await insertMultiple(this.db, docs);
} else {
Log.info('No documents to restore');
}
Log.info('Restored vectorstore from backup');
Log.debug(this.db.data.docs.docs);
}
Can I fix the error like this?