MCPcopy Create free account
hub / github.com/MemTensor/MemOS / updateChunk

Method updateChunk

packages/memos-core/src/storage/sqlite.ts:1404–1438  ·  view source on GitHub ↗
(chunkId: string, fields: { summary?: string; content?: string; role?: string; kind?: string; owner?: string })

Source from the content-addressed store, hash-verified

1402 // ─── Update ───
1403
1404 updateChunk(chunkId: string, fields: { summary?: string; content?: string; role?: string; kind?: string; owner?: string }): boolean {
1405 const sets: string[] = [];
1406 const params: unknown[] = [];
1407
1408 if (fields.summary !== undefined) {
1409 sets.push("summary = ?");
1410 params.push(fields.summary);
1411 }
1412 if (fields.content !== undefined) {
1413 sets.push("content = ?");
1414 params.push(fields.content);
1415 }
1416 if (fields.role !== undefined) {
1417 sets.push("role = ?");
1418 params.push(fields.role);
1419 }
1420 if (fields.kind !== undefined) {
1421 sets.push("kind = ?");
1422 params.push(fields.kind);
1423 }
1424 if (fields.owner !== undefined) {
1425 sets.push("owner = ?");
1426 params.push(fields.owner);
1427 }
1428 if (sets.length === 0) return false;
1429
1430 sets.push("updated_at = ?");
1431 params.push(Date.now());
1432 params.push(chunkId);
1433
1434 const result = this.db.prepare(
1435 `UPDATE chunks SET ${sets.join(", ")} WHERE id = ?`,
1436 ).run(...params);
1437 return result.changes > 0;
1438 }
1439
1440 /**
1441 * Find user-role chunks that contain system-injected content that should

Callers 3

handleUpdateMethod · 0.45

Calls 3

prepareMethod · 0.80
runMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected