MCPcopy
hub / github.com/PromtEngineer/localGPT / update_index_metadata

Method update_index_metadata

backend/database.py:428–441  ·  view source on GitHub ↗

Merge new key/values into an index's metadata JSON column.

(self, index_id: str, updates: dict)

Source from the content-addressed store, hash-verified

426 return deleted
427
428 def update_index_metadata(self, index_id: str, updates: dict):
429 """Merge new key/values into an index's metadata JSON column."""
430 conn = sqlite3.connect(self.db_path)
431 conn.row_factory = sqlite3.Row
432 cur = conn.execute('SELECT metadata FROM indexes WHERE id=?', (index_id,))
433 row = cur.fetchone()
434 if row is None:
435 conn.close()
436 raise ValueError("Index not found")
437 existing = json.loads(row['metadata'] or '{}')
438 existing.update(updates)
439 conn.execute('UPDATE indexes SET metadata=?, updated_at=? WHERE id=?', (json.dumps(existing), datetime.now().isoformat(), index_id))
440 conn.commit()
441 conn.close()
442
443 def inspect_and_populate_index_metadata(self, index_id: str) -> dict:
444 """

Callers 4

handle_build_indexMethod · 0.80
handle_indexMethod · 0.80

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected