all repos — min @ 9a4390d0d79a3daa0f005fd0137e89463d190bb5

A small but practical concatenative programming language.

Documented the dstore module.
h3rald h3rald@h3rald.com
Mon, 21 Dec 2020 03:27:42 +0100
commit

9a4390d0d79a3daa0f005fd0137e89463d190bb5

parent

9207703e98ed997da0a71f9e637c8fbad02a2204

M Min_DeveloperGuide.mdMin_DeveloperGuide.md

@@ -105,6 +105,10 @@ ### `dict` Module

{@ site/contents/reference-dict.md || 1 @} +### `dstore` Module + +{@ site/contents/reference-dstore.md || 1 @} + ### `io` Module {@ site/contents/reference-io.md || 1 @}
M next-release.mdnext-release.md

@@ -1,1 +1,2 @@

* Added **encode-url**, **decode-url**, **parse-url** symbols. +* Added **dstore** module providing support for simple, persistent, in-memory JSON stores.
M site/contents/_defs_.mdsite/contents/_defs_.md

@@ -9,9 +9,11 @@ {{3 => [<sub>3</sub>](class:kwd)}}

{{4 => [<sub>4</sub>](class:kwd)}} {{e => [dict:error](class:kwd)}} {{tinfo => [dict:timeinfo](class:kwd)}} +{{dstore => [dict:datastore](class:kwd)}} {{d => [dict](class:kwd)}} {{d1 => [dict<sub>1</sub>](class:kwd)}} {{d2 => [dict<sub>2</sub>](class:kwd)}} +{{s0p => [dict<sub>\*</sub>](class:kwd)}} {{flt => [float](class:kwd)}} {{i => [int](class:kwd)}} {{i1 => [int<sub>1</sub>](class:kwd)}}
A site/contents/reference-dstore.md

@@ -0,0 +1,44 @@

+----- +content-type: "page" +title: "dstore Module" +----- +{@ _defs_.md || 0 @} + +{#op||dsdelete||{{datoee}} {{sl}}||{{dstore}}|| +Removes an item from the datastore {{dstore}}. The item is uniquely identified by {{sl}}, which contains the collection containing the item and the item id, separated by a forward slash (/). Puts the reference to the modified datastore back on tbe stack. +#} + +{#op||dsget||{{dstore}} {{sl}}||{{d}}|| +Retrieves item {{d}} from datastore {{dstore}}. {{d}} is retrieved by specifying {{sl}}, which contains the collection containing the item and the item id, separated by a forward slash (/). +#} + +{#op||dsinit||{{sl}}||{{dstore}}|| +Initializes a bew datastore by creating the {{sl}} JSON file. Puts the datastore instance on the stack. #} + +{#op||dspost||{{dstore}} {{sl}} {{d}}||{{dstore}}|| +Adds the dictionary {{d}} to the datastore {{dstore}} inside collection {{sl}}, generating and adding a unique **id** field to {{d}}. If the collection {{sl}} does not exist it is created. Puts the reference to the modified datastore back on tbe stack. +#} + +{#op||dsput||{{dstore}} {{sl}} {{d}}||{{dstore}}|| +Adds the dictionary {{d}} to the datastore {{dstore}}. {{sl}} contains the collection where {{d}} will be placed and the id of {{d}}, separated by a forward slash (/). If the collection {{sl}} does not exist it is created. Puts the reference to the modified datastore back on tbe stack. +#} + +{#op||dsquery||{{dstore}} {{sl}} {{q}}||({{d0p}})|| +> Retrieves a quotation of dictionaries from the collection {{sl}} of datastore {{dstore}} obtained by applying {{q}} as a filter to each item of the collection, picking only the elements that match the filter. +> +> > %sidebar% +> > Example +> > +> > Assuming that **ds** is a datastore, the following program retrieves all elements of teh collection **posts** whose author field is set to "h3rald": +> > ds "posts" (/author "h3rald" ==) dsquery +#} + +{#op||dsread||{{sl}}||{{dstore}}|| +Reads the previously-created datastore from the file {{sl}} and puts the resulting datastore instance on the stack. +#} + +{#op||dswrite||{{dstore}}||{{dstore}}|| +Writes the contents of the datastore {{dstore}} to the filesystem. +#} + +
M site/contents/reference.mdsite/contents/reference.md

@@ -14,6 +14,8 @@ {#link-module||seq#}

: Defines operators for quotations, like map, filter, reduce, etc. {#link-module||dict#} : Defines operators for dictionaries, like dget, ddup, dset, etc. +{#link-module||dstore#} +: Provides support for simple, persistent, in-memory JSON stores. {#link-module||io#} : Provides operators for reading and writing files as well as printing to STDOUT and reading from STDIN. {#link-module||fs#}

@@ -29,7 +31,7 @@ : Provides operators to perform simple mathematical operations on integer and floating point numbers.

{#link-module||time#} : Provides a few basic operators to manage dates, times, and timestamps. {#link-module||crypto#} -: Provides operators to compute hashes (MD5, SHA1, SHA224, SHA256, SHA384, sha512), base64 encoding/decoding, and AES encryption/decryption. +: Provides operators to compute hashes (MD4, MD5, SHA1, SHA224, SHA256, SHA384, sha512), base64 encoding/decoding, and AES encryption/decryption. {#link-module||math#} : Provides many mathematical operators and constants such as trigonometric functions, square root, logarithms, etc. {#link-module||net#}

@@ -113,6 +115,14 @@ "ipv4" :domain

"stream" :type "tcp" :protocol ;socket + } +{{dstore}} +: A datastore dictionary that must be created through the {#link-operator||dstore||dsinit#} or {#link-operator||dstore||dsread#} operator: + + { + {} :data + "path/to/file.json" :path + ;datastore } {{req}} : A request dictionary, representing an HTTP request to be performed through the operators exposed by the {#link-module||http#}: