Prisma-backed implementation of the @basaltkit/commentsCommentStore — per-resource threads with @mentions and resolve/reopen — for production databases (PostgreSQL, MySQL, …).
You bring a generated PrismaClient with the Comment model; the store only touches that delegate. The production counterpart to @basaltkit/comments-sqlite.
bash
pnpm add @basaltkit/comments-prisma # peer: @basaltkit/comments ; you already have @prisma/client
The reference schema above is written for PostgreSQL (and works on SQLite), where a bare String is TEXT. On MySQL Prisma makes it VARCHAR(191), and a server outside strict mode truncates a longer value silently — the write succeeds, and the value read back is not the one written. A long comment is saved cut short while the author is told it was saved. MySQL also has no scalar lists, so the MySQL variant stores mentions as Json — the store reads and writes the same array either way. update() (an edited body) is checked too.
Copy schema.mysql.prisma instead (exported as @basaltkit/comments-prisma/schema.mysql.prisma; basalt prisma:sync picks it when your datasource is mysql): the free-text columns are widened with native types, the keys stay VARCHAR(191) so they can be indexed.
Turn on the guard, so a value that still would not fit is refused (ColumnLengthError, code COLUMN_LENGTH_EXCEEDED, status 422, nothing written) instead of cut:
'mysql' is commentsMysqlColumnLimits — the capacities of schema.mysql.prisma. A number is a limit in characters (VARCHAR(n)), { bytes: n } a limit in UTF-8 bytes (the TEXT family). Widened a column yourself? Spread the preset and raise it: { Comment: { ...commentsMysqlColumnLimits.Comment, resourceType: 500 } }.
Keep MySQL in strict mode (STRICT_TRANS_TABLES) as well.
Package reference
Mirrors the package README (single source). Install
@basaltkit/comments-prismav1.1.0— npm · source.<p align="center"> <a href="https://basaltkit-docs.pages.dev"> <img src="https://basaltkit-docs.pages.dev/social-card.png" alt="Basalt" width="440"> </a> </p>
@basaltkit/comments-prisma
Prisma-backed implementation of the
@basaltkit/commentsCommentStore— per-resource threads with @mentions and resolve/reopen — for production databases (PostgreSQL, MySQL, …).You bring a generated
PrismaClientwith theCommentmodel; the store only touches that delegate. The production counterpart to@basaltkit/comments-sqlite.1. Add the model
Copy the model from the bundled reference schema (
@basaltkit/comments-prisma/schema.prisma) into yourschema.prisma:Then
prisma migrate devandprisma generate.2. Wire the store
MySQL
The reference schema above is written for PostgreSQL (and works on SQLite), where a bare
StringisTEXT. On MySQL Prisma makes itVARCHAR(191), and a server outside strict mode truncates a longer value silently — the write succeeds, and the value read back is not the one written. A long comment is saved cut short while the author is told it was saved. MySQL also has no scalar lists, so the MySQL variant storesmentionsasJson— the store reads and writes the same array either way.update()(an edited body) is checked too.Copy
schema.mysql.prismainstead (exported as@basaltkit/comments-prisma/schema.mysql.prisma;basalt prisma:syncpicks it when your datasource ismysql): the free-text columns are widened with native types, the keys stayVARCHAR(191)so they can be indexed.Turn on the guard, so a value that still would not fit is refused (
ColumnLengthError, codeCOLUMN_LENGTH_EXCEEDED, status 422, nothing written) instead of cut:'mysql'iscommentsMysqlColumnLimits— the capacities ofschema.mysql.prisma. A number is a limit in characters (VARCHAR(n)),{ bytes: n }a limit in UTF-8 bytes (theTEXTfamily). Widened a column yourself? Spread the preset and raise it:{ Comment: { ...commentsMysqlColumnLimits.Comment, resourceType: 500 } }.Keep MySQL in strict mode (
STRICT_TRANS_TABLES) as well.Unset (the default), nothing is checked — PostgreSQL and SQLite are unaffected. See the MySQL section of the persistence guide.
Notes
undefinedclears the column (reopen), an absent key is left untouched.DateTimeand converted to/from the epoch-ms numbers the@basaltkit/commentscontract uses.PrismaCommentsClienttypes delegate arguments asany(returns stay precise) so a realPrismaClientis assignable and passes directly.License
MIT