From 50c91a360ac3f42682d998a826087c4bb41d0af4 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Wed, 26 Aug 2026 21:49:42 +0200 Subject: add ReadOnly plan option --- oblast.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'oblast.go') diff --git a/oblast.go b/oblast.go index 588471b..837742d 100644 --- a/oblast.go +++ b/oblast.go @@ -144,6 +144,15 @@ func StructTagKeyIs(key string) PlanOption { return func(opts *planOpts) { opts.StructTagKey = key } } +// ReadOnly is a PlanOption that disables all write operations for the resulting [Store] type +// (i.e., [Store.Insert], [Store.Update], [Store.Upsert] and [Store.Delete]). +// Besides read-only tables (i.e. tables where the current user lacks write permissions), +// this is useful for record types that only model a few columns of a table and which, +// when used in write operations, might result in incomplete records. +func ReadOnly() PlanOption { + return func(opts *planOpts) { opts.ReadOnly = true } +} + // Store holds information on how to read and write data into record type R, // and can also be used to execute autogenerated queries if the respective [PlanOption] values were provided during [NewStore]. type Store[R any] struct { -- cgit v1.3.1