diff --git a/README.md b/README.md index 540f1f4..039ad93 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,17 @@ async function patchDocument(ctx: MutationCtx, documentId: Id<"documents">, patc const document = await ctx.db.get(documentId); await documentAuditLog.update(ctx, documentId, document); } + +async function insertDocument(ctx: MutationCtx, documentId: Id<"documents">, newDoc: WithoutSystemFields>) { + const documentId = await ctx.db.insert("documents", newDoc); + const document = await ctx.db.get(documentId); + await documentAuditLog.update(ctx, documentId, document); +} + +async function deleteDocument(ctx: MutationCtx, documentId: Id<"documents">) { + await ctx.db.delete(documentId); + await documentAuditLog.update(ctx, documentId, null); +} ``` Or attach a [trigger](https://www.npmjs.com/package/convex-helpers#triggers) to automatically write to the history table when a mutation changes a document: diff --git a/package.json b/package.json index f63e65c..e094ebe 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "email": "support@convex.dev", "url": "https://github.com/ldanilek/table-history/issues" }, - "version": "0.1.1", + "version": "0.1.2", "license": "Apache-2.0", "keywords": [ "convex",