MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / insertNoteComment

Function insertNoteComment

shared-edge/src/kysely.ts:753–790  ·  view source on GitHub ↗
(
	noteId: RemoteNoteId,
	text: string,
	authorId: UserId,
)

Source from the content-addressed store, hash-verified

751}
752
753export async function insertNoteComment(
754 noteId: RemoteNoteId,
755 text: string,
756 authorId: UserId,
757) {
758 const noteDbId = fromBase64Url(noteId)
759 await db.transaction().execute(
760 async (tx) =>
761 await Promise.all([
762 db
763 .selectFrom('note')
764 .select(['id'])
765 .where('note.id', '=', noteDbId)
766 .executeTakeFirst()
767 .then((r) => {
768 if (r == null) throwExp(`Note ${noteId} not found.`)
769 }),
770 tx
771 .updateTable('note')
772 .set({
773 commentsCount: (x) => sql`${x.ref('commentsCount')} + 1`,
774 })
775 .where('note.id', '=', noteDbId)
776 .execute(),
777 tx
778 .insertInto('noteComment')
779 .values({
780 id: unhex(hexId()),
781 authorId,
782 level: 0,
783 noteId: noteDbId,
784 votes: '',
785 text,
786 })
787 .execute(),
788 ]),
789 )
790}
791
792export async function insertNoteChildComment(
793 parentCommentId: CommentId,

Callers 1

noteRouter.tsFile · 0.90

Calls 4

throwExpFunction · 0.90
hexIdFunction · 0.90
fromBase64UrlFunction · 0.85
unhexFunction · 0.85

Tested by

no test coverage detected