MCPcopy Create free account
hub / github.com/codemix/graph / addVertex

Method addVertex

packages/y-graph-storage/src/YGraphStorage.ts:237–256  ·  view source on GitHub ↗
(vertex: StoredVertex)

Source from the content-addressed store, hash-verified

235 }
236
237 public addVertex(vertex: StoredVertex): void {
238 const [label, uuid] = parseElementId(vertex.id);
239 const schema = this.#config.schema.vertices[label];
240 if (schema == null) {
241 throw new LabelNotFoundError(label);
242 }
243 const collection = this.getVertexCollectionMap(label);
244 this.transact(() => {
245 const map = new Y.Map<unknown>();
246
247 collection.set(uuid, map);
248 for (const [key] of Object.entries(schema.properties)) {
249 const value = vertex.properties[key as keyof typeof vertex.properties];
250 if (value === undefined) {
251 continue;
252 }
253 map.set(key, value);
254 }
255 });
256 }
257
258 public deleteVertex(id: ElementId): void {
259 const [label, uuid] = parseElementId(id);

Callers

nothing calls this directly

Calls 3

transactMethod · 0.95
parseElementIdFunction · 0.90

Tested by

no test coverage detected