diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-08-26 21:49:42 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-08-26 21:49:42 +0200 |
| commit | 50c91a360ac3f42682d998a826087c4bb41d0af4 (patch) | |
| tree | d96f112c4fe4d0eaac1b018ff568ab7343068e3b /oblast.go | |
| parent | d2118d8e07f9486d8880eee59d5ff83cd8c13c0c (diff) | |
| download | go-oblast-50c91a360ac3f42682d998a826087c4bb41d0af4.tar.gz | |
add ReadOnly plan option
Diffstat (limited to 'oblast.go')
| -rw-r--r-- | oblast.go | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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 { |
