aboutsummaryrefslogtreecommitdiff
path: root/oblast.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-08-26 21:49:42 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-08-26 21:49:42 +0200
commit50c91a360ac3f42682d998a826087c4bb41d0af4 (patch)
treed96f112c4fe4d0eaac1b018ff568ab7343068e3b /oblast.go
parentd2118d8e07f9486d8880eee59d5ff83cd8c13c0c (diff)
downloadgo-oblast-50c91a360ac3f42682d998a826087c4bb41d0af4.tar.gz
add ReadOnly plan option
Diffstat (limited to 'oblast.go')
-rw-r--r--oblast.go9
1 files changed, 9 insertions, 0 deletions
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 {