MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / getNodeById

Method getNodeById

src/db/queries.ts:758–779  ·  view source on GitHub ↗

* Get a node by ID

(id: string)

Source from the content-addressed store, hash-verified

756 * Get a node by ID
757 */
758 getNodeById(id: string): Node | null {
759 // Check cache first
760 if (this.nodeCache.has(id)) {
761 const cached = this.nodeCache.get(id)!;
762 // Move to end to implement LRU (delete and re-add)
763 this.nodeCache.delete(id);
764 this.nodeCache.set(id, cached);
765 return cached;
766 }
767
768 if (!this.stmts.getNodeById) {
769 this.stmts.getNodeById = this.db.prepare('SELECT * FROM nodes WHERE id = ?');
770 }
771 const row = this.stmts.getNodeById.get(id) as NodeRow | undefined;
772 if (!row) {
773 return null;
774 }
775
776 const node = rowToNode(row);
777 this.cacheNode(node);
778 return node;
779 }
780
781 /**
782 * Batch lookup: fetch many nodes by ID in a single SQL round-trip.

Callers

nothing calls this directly

Calls 6

cacheNodeMethod · 0.95
rowToNodeFunction · 0.85
hasMethod · 0.80
getMethod · 0.65
prepareMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected