MCPcopy
hub / github.com/colbymchenry/codegraph / getNodeById

Method getNodeById

src/db/queries.ts:415–436  ·  view source on GitHub ↗

* Get a node by ID

(id: string)

Source from the content-addressed store, hash-verified

413 * Get a node by ID
414 */
415 getNodeById(id: string): Node | null {
416 // Check cache first
417 if (this.nodeCache.has(id)) {
418 const cached = this.nodeCache.get(id)!;
419 // Move to end to implement LRU (delete and re-add)
420 this.nodeCache.delete(id);
421 this.nodeCache.set(id, cached);
422 return cached;
423 }
424
425 if (!this.stmts.getNodeById) {
426 this.stmts.getNodeById = this.db.prepare('SELECT * FROM nodes WHERE id = ?');
427 }
428 const row = this.stmts.getNodeById.get(id) as NodeRow | undefined;
429 if (!row) {
430 return null;
431 }
432
433 const node = rowToNode(row);
434 this.cacheNode(node);
435 return node;
436 }
437
438 /**
439 * 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
setMethod · 0.80
getMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected