{"version":"2.1.267","anchor":"write-db-batch-entries-can-now-pin-an-individual-document-ve","canonical_anchor":"artifact-database-write-db-batches-now-support-per-entry-ver","heading":"write_db batch writes support per-entry version pins (if_version)","tier":"use","area":"Artifacts","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.267\/e\/write-db-batch-entries-can-now-pin-an-individual-document-ve","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.267","markdown":"### write_db batch writes support per-entry version pins (if_version)\n\nBatch writes to an artifact's database can now pin individual entries to expected versions, with clearer conflict errors\n\n**What**\n\n- `write_db` batch operations can now include an `if_version` on each entry, individually pinning specific documents to an expected version so the whole batch fails if any pinned document changed since it was read.\n\n- A new `delete` db_op is added to write_db, working alongside `set`, `update`, `str_replace`, and it too can carry an `if_version` constraint.\n\n- If the number of entries in a batch changes after approval (entries added or removed), the write is now rejected with \"this batch no longer lists the writes that were approved (entries were added or removed)\".\n\n- Batches now track a version pin per entry (`entryPins`), not just one overall pin, and a server that doesn't support batch writes with version pins at all now gets its own explicit error.\n\n- Version-mismatch errors are clearer: when the document's current version is known, the error tells you the new version number to plan against; when it's unknown or deleted, it tells you to check whether the document still exists, and for deletes says there's nothing left to do while for other operations it suggests re-creating with a plain `set`. The error also names which specific write in the batch was stale.\n\n**Why** This lets tools safely make several conditional writes at once instead of just one: if any pinned document was modified elsewhere since being read, none of the batch is applied, and the error message tells you exactly which write conflicted and what to do about it, instead of silently overwriting concurrent edits.\n\n- Area: Artifacts\n- Names: `if_version`\n- Tier: Use it now\n- Useful: 3\/5\n- Signal: 2\/5"}