qs

Types

pub type Query(v) =
  Dict(String, v)
pub type QueryBasic =
  Query(List(String))

Functions

pub fn delete(
  query: Dict(String, a),
  key: String,
) -> Dict(String, a)

Delete a key from the query

pub fn empty() -> Dict(String, a)

Make an empty Query

pub fn get(
  query: Dict(String, a),
  key: String,
) -> Result(a, String)

Get values from the query

pub fn has_key(query: Dict(String, a), key: String) -> Bool

Tell if the query has the given key

pub fn insert(
  query: Dict(String, a),
  key: String,
  value: a,
) -> Dict(String, a)

Insert a value in the query Replaces existing values

pub fn merge(
  a: Dict(String, a),
  b: Dict(String, a),
) -> Dict(String, a)

Merge two Querys. Second query takes precedence.

pub fn parse(
  qs: String,
) -> Result(Dict(String, List(String)), String)

Parse a query string. Values that cannot be parsed are ignored.

Example

"?color=red&tags=large&tags=wool"
|> qs.parse

==

Ok(
  dict.from_list(
    [ #("color", ["red"]), #("tags", ["large", "wool"]) ]
  )
)
pub fn serialize(query: Dict(String, List(String))) -> String

Serialize a query

Example

[ #("color", ["red"]), #("tag", ["large", "wool"]) ]
|> qs.serialize

==

"?color=red&tag=large&tag=wool"
Search Document