[{"name":"Col","comment":" Represents a \"column\" semantic, with support for tracking changes over time.\n\n\n# Type\n\n@docs Col\n\n\n# Create, update\n\n@docs init, cons, touch\n\n\n# Access values\n\n@docs value, updatedAt, history\n\n\n# Aggregation\n\n@docs toUpdatedAt\n\n","unions":[{"name":"Col","comment":" Opaque type representing a \"column\".\n","args":["a"],"cases":[]}],"aliases":[],"values":[{"name":"cons","comment":" Update a value in a `Col a`, tracking changes.\n","type":"Time.Posix -> a -> Col.Col a -> Col.Col a"},{"name":"history","comment":" Get all changes on a `Col a`, in order from newest to oldest.\n","type":"Col.Col a -> List.List ( Time.Posix, a )"},{"name":"init","comment":" Create a new `Col a`.\n","type":"Time.Posix -> a -> Col.Col a"},{"name":"toUpdatedAt","comment":" For a list of `Col` values on a record `a`, calculate when the record was last updated.\n","type":"List.List (a -> Time.Posix) -> Time.Posix -> a -> Time.Posix"},{"name":"touch","comment":" Update a `Col a`'s timestamp without adding a record to its history.\n","type":"Time.Posix -> Col.Col a -> Col.Col a"},{"name":"updatedAt","comment":" Get a `Col a`'s timestamp\\`.\n","type":"Col.Col a -> Time.Posix"},{"name":"value","comment":" Get a value from a `Col a`.\n","type":"Col.Col a -> a"}],"binops":[]},{"name":"Table","comment":" Represents a \"table\" semantic, where a \"table\" is a a dictionary of values that have a unique identity, and a \"created at\" timestamp.\n\nIn a traditional relational database management system, the database engine provides a unique identity and can generate timestamps;\nthe `Table` type takes responsibility for mediating those operations.\n\n\n# Types\n\n@docs Table, init\n\n@docs Row, Id\n\n\n# Configuration\n\n@docs Config, define\n\n@docs Spec, Index, Predicate, toSpec, toSpecId, toSpecBool, withIndex\n\n\n# Commands\n\n@docs insert, insertMany, update, delete\n\n\n# Queries\n\n@docs getById, where_, filter, select\n\n\n# JSON\n\nNote: There is no encoder or decoder for `Table a`. Serializing and deserializing identity generation would be a tricky thing to have to do, so for now I am making the artistic choice to deal with it by not dealing with it at all.\n\n@docs idEncoder, idDecoder\n@docs rowEncoder, rowDecoder\n\n","unions":[{"name":"Config","comment":" Configuration details for a table.\n","args":["a"],"cases":[]},{"name":"Id","comment":" Represents a unique ID for a `Row` in a `Table a`.\n","args":["a"],"cases":[]},{"name":"Index","comment":" Represent an index for a table.\n\nInternally, an index is:\n\n  - A unique identifier (i.e., the index name)\n  - A map between a property on an `a` and an `Int`\n\nWhen you _query_ a table, you query it by its indexes. This doesn't mean that you need to create an index for every column! The columns\nthat you should create indexes for are the columns that will help you identify a record, or identify a group of records by some column that\nis a member of a smaller set compared to other columns.\n\nConsider the following:\n\n    module User exposing (..)\n\n    import Table\n\n    type alias Record =\n        { emailAddress : String\n        , catchphrase : String\n        , role : Role\n        }\n\n    type Role\n        = Admin\n        | Member\n\nIf we need to run queries against `User.Record` to find all users that are `Admin` users, it would make sense to create an index on the `.role`\ncolumn, because the `Role` type is a member of a set that only has two values - `Admin` or `Member`.\n\nIt wouldn't make much sense to create an index on the `.catchphrase` column - since that column is likely going to be unique for each user, anyway - so if we really needed to do a query against\nthe `.catchphrase` column, we would have to consider every record separately, no matter what.\n\n","args":["a"],"cases":[]},{"name":"Predicate","comment":" An opaque function that acts as an interface between the `Index a` values within a table's `Config a`,\nand the type of a column that has an `Index a`.\n\nSee usage at [`where_`](#where_) for more information.\n\n","args":["a","b"],"cases":[]},{"name":"Table","comment":" Opaque type representing a \"table\".\n","args":["a"],"cases":[]}],"aliases":[{"name":"Row","comment":" Represents a row created in a `Table a`.\n","args":["a"],"type":"{ id : Table.Id a, value : a, createdAt : Time.Posix }"},{"name":"Spec","comment":" A `Spec a b` is a record that contains:\n\n  - An `Index a`, which makes lookups faster for a given column\n  - A `Predicate a b`, which allows searching for a `Row a` in a `Table a` by some value `b`, which has the same type as the value indexed\n\n","args":["a","b"],"type":"{ index : Table.Index a, is : Table.Predicate a b }"}],"values":[{"name":"define","comment":" Define a table's configuration.\n\nThis value returns an empty `Config a`, and can be \"built\" with other functions in this module whose type signature ends in `Config a -> Config a`.\n\n","type":"Table.Config a"},{"name":"delete","comment":" Delete a record from a `Table`.\n","type":"Table.Config a -> Time.Posix -> Table.Id a -> Table.Table a -> Table.Table a"},{"name":"filter","comment":" Query values in a table based on a predicate derived from any column value.\n\nThis does _not_ use any of a table's indexes. If you need to use `filter`, then consider either:\n\n  - Creating an `Index a` so that you can have a `Predicate a b` to use with `where_`, or\n  - Filtering the result set down as much as possible by `where_` first, before applying `filter`\n\n","type":"(a -> Basics.Bool) -> Table.Table a -> Table.Table a"},{"name":"getById","comment":" Get a value by its `id`.\n","type":"Table.Id a -> Table.Table a -> Maybe.Maybe (Table.Row a)"},{"name":"idDecoder","comment":" Decoder for an `Id a`.\n","type":"Json.Decode.Decoder (Table.Id a)"},{"name":"idEncoder","comment":" Encoder for an `Id a`.\n","type":"Table.Id a -> Json.Encode.Value"},{"name":"init","comment":" Create a new `Table`.\n","type":"Table.Table a"},{"name":"insert","comment":" Insert a record into a `Table`.\n","type":"Table.Config a -> Time.Posix -> a -> Table.Table a -> ( Table.Row a, Table.Table a )"},{"name":"insertMany","comment":" Insert many records into a `Table`.\n","type":"Table.Config a -> Time.Posix -> List.List a -> Table.Table a -> ( List.List (Table.Row a), Table.Table a )"},{"name":"rowDecoder","comment":" Decoder for a `Row a`.\n","type":"Json.Decode.Decoder a -> Json.Decode.Decoder (Table.Row a)"},{"name":"rowEncoder","comment":" Encoder for a `Row a`.\n","type":"(a -> Json.Encode.Value) -> Table.Row a -> Json.Encode.Value"},{"name":"select","comment":" Select rows from a `Table a`.\n\nThis will operate on _all_ rows in a given `Table a`, so it may be wise to use `where_` and `filter` to narrow the `Table` to _what you actually want_ before calling `select`.\n\n","type":"(Table.Row a -> b) -> Table.Table a -> List.List b"},{"name":"toSpec","comment":" Create an `Index a` and `Predicate a b` by providing a unique name for the index, and a string representation of the indexed value.\n","type":"String.String -> (a -> b) -> (b -> String.String) -> Table.Spec a b"},{"name":"toSpecBool","comment":" Convenience function to create a `Spec a b` where the `b` is a `Bool`.\n","type":"String.String -> (a -> Basics.Bool) -> Table.Spec a Basics.Bool"},{"name":"toSpecId","comment":" Convenience function to create a `Spec a b` where the `b` is an `Id b` - i.e., where you'd like to index or filter by a column in your table\nthat is an `Id b` for some `Table b`.\n","type":"String.String -> (a -> Table.Id b) -> Table.Spec a (Table.Id b)"},{"name":"update","comment":" Update a record in a `Table`.\n\nThe `Table a` type doesn't track \"updated at\", since it's assumed that if you care about that, you will wrap each column whose \"updated at\" time is meaningful, in a `Col a`.\n\n`update` doesn't return a tuple of the updated record and the updated table; `insert` only returns a tuple because `insert` is responsible for creating the `Id a` value.\n\n`update` is an expensive operation, because it rebuilds the indexes for a `Table a`; prefer data structures such that \"things that change often\" are defined as calls to `insert`,\nand \"things that only change once in awhile\" are handled by calls to `update`.\n\n","type":"Table.Config a -> Table.Id a -> Time.Posix -> a -> Table.Table a -> Table.Table a"},{"name":"where_","comment":" Query values in a table based on a `Predicate a b`.\n","type":"Table.Predicate a b -> b -> Table.Table a -> Table.Table a"},{"name":"withIndex","comment":" Add an `Index a` to a `Table a`.\n","type":"Table.Index a -> Table.Config a -> Table.Config a"}],"binops":[]}]