fix: Correct SurrealDB record creation to use table+ID array format
The SurrealDB JavaScript client was interpreting "node:uuid" as a table name
instead of a record ID, creating separate schemaless tables for each node.
Changed from:
db.create("node:uuid", data)
To:
db.create(['node', 'uuid'], data)
This ensures nodes are created as records in the main 'node' table with the
specified UUID, not as separate tables.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,8 @@ export async function POST(request: NextRequest) {
|
|||||||
const createdAt = new Date().toISOString();
|
const createdAt = new Date().toISOString();
|
||||||
|
|
||||||
// Generate a unique node ID upfront (we'll use this for the detail page link)
|
// Generate a unique node ID upfront (we'll use this for the detail page link)
|
||||||
const nodeId = `node:${crypto.randomUUID()}`;
|
const nodeUuid = crypto.randomUUID();
|
||||||
|
const nodeId = `node:${nodeUuid}`;
|
||||||
const detailUrl = `${process.env.NEXT_PUBLIC_APP_URL || 'https://ponderants.app'}/galaxy/${encodeURIComponent(nodeId)}`;
|
const detailUrl = `${process.env.NEXT_PUBLIC_APP_URL || 'https://ponderants.app'}/galaxy/${encodeURIComponent(nodeId)}`;
|
||||||
|
|
||||||
// --- Step 1: Write to Source of Truth (ATproto) ---
|
// --- Step 1: Write to Source of Truth (ATproto) ---
|
||||||
@@ -235,7 +236,9 @@ export async function POST(request: NextRequest) {
|
|||||||
nodeData.embedding = embedding;
|
nodeData.embedding = embedding;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newNode = await db.create(nodeId, nodeData);
|
// Use array format to specify table and ID separately
|
||||||
|
// SurrealDB client expects ['table', 'id'] not 'table:id'
|
||||||
|
const newNode = await db.create(['node', nodeUuid], nodeData);
|
||||||
|
|
||||||
// Handle linking
|
// Handle linking
|
||||||
if (links && links.length > 0) {
|
if (links && links.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user