Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Doc<"documents">>) {
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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading