MCPcopy
hub / github.com/vercel/chatbot / saveDocument

Function saveDocument

lib/db/queries.ts:280–308  ·  view source on GitHub ↗
({
  id,
  title,
  kind,
  content,
  userId,
}: {
  id: string;
  title: string;
  kind: ArtifactKind;
  content: string;
  userId: string;
})

Source from the content-addressed store, hash-verified

278}
279
280export async function saveDocument({
281 id,
282 title,
283 kind,
284 content,
285 userId,
286}: {
287 id: string;
288 title: string;
289 kind: ArtifactKind;
290 content: string;
291 userId: string;
292}) {
293 try {
294 return await db
295 .insert(document)
296 .values({
297 id,
298 title,
299 kind,
300 content,
301 userId,
302 createdAt: new Date(),
303 })
304 .returning();
305 } catch (error) {
306 throw new ChatSDKError('bad_request:database', 'Failed to save document');
307 }
308}
309
310export async function getDocumentsById({ id }: { id: string }) {
311 try {

Callers 2

createDocumentHandlerFunction · 0.90
POSTFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…