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

Method getNodeById

src/db/queries.ts:802–823  ·  view source on GitHub ↗

* Get a node by ID

(id: string)

Source from the content-addressed store, hash-verified

800 * Get a node by ID
801 */
802 getNodeById(id: string): Node | null {
803 // Check cache first
804 if (this.nodeCache.has(id)) {
805 const cached = this.nodeCache.get(id)!;
806 // Move to end to implement LRU (delete and re-add)
807 this.nodeCache.delete(id);
808 this.nodeCache.set(id, cached);
809 return cached;
810 }
811
812 if (!this.stmts.getNodeById) {
813 this.stmts.getNodeById = this.db.prepare('SELECT * FROM nodes WHERE id = ?');
814 }
815 const row = this.stmts.getNodeById.get(id) as NodeRow | undefined;
816 if (!row) {
817 return null;
818 }
819
820 const node = rowToNode(row);
821 this.cacheNode(node);
822 return node;
823 }
824
825 /**
826 * Batch lookup: fetch many nodes by ID in a single SQL round-trip.

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected