diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index a600de5..bd94677 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -10,4 +10,3 @@ - [Entity History](./sec-8-history.md) - [Relation Algebra](./sec-9-algebra.md) - [Errors Messages](./sec-10-errors.md) - diff --git a/book/src/sec-10-errors.md b/book/src/sec-10-errors.md index 3dd217c..0bf9a65 100644 --- a/book/src/sec-10-errors.md +++ b/book/src/sec-10-errors.md @@ -16,7 +16,7 @@ Woori DB has a variety of Error messages, from WQL when parsing the transaction - `Io(io::Error)` - Failed to read or write file. - `QueryFormat(String)` - WQL error. - `EntityAlreadyCreated()` - Entity `entity_name` already created in the database. -- `EntityNotCreated()` - tx or query at entity tree dooes not contain key `entity_name`. +- `EntityNotCreated()` - tx or query at entity tree does not contain key `entity_name`. - `EntityNotCreatedWithUniqueness()` - this error only occurs if a failed write to the bank happened. Migration to fix data inconsistency may be needed. - `Serialization(ron::Error)` - Ron serialization error in wql context. - `UuidNotCreatedForEntity(, Uuid)` - If you try to `UPDATE/DELETE/EVICT/SELECT` an Uuid that `entity_name` does not contain. @@ -72,7 +72,7 @@ Woori DB has a variety of Error messages, from WQL when parsing the transaction - "SELECT expression should be followed by `*` for ALL keys or `#{key_names...}` for some keys" and "SELECT arguments set should start with `#{` and end with `}`" - "Uuids in `IDS IN` are reuired to be inside a `#{` and `}`" - "START date and END date should be the same date." - - "WHERE clauses must be contained inside ` {...}`" + - "WHERE clauses must be contained inside `{...}`" - `Required content`: - "MATCH requires ALL or ANY symbols". It is necessary to include `ANY` or `ALL` conditions after `MATCH` keyword. diff --git a/book/src/sec-4-wql.md b/book/src/sec-4-wql.md index 13a17b5..6eb849e 100644 --- a/book/src/sec-4-wql.md +++ b/book/src/sec-4-wql.md @@ -11,15 +11,15 @@ - [SET UPDATE](#update-set) replaces the sent entity map as the entity's map content. - [CONTENT UPDATE](#update-content) updates numerical and string the current entity's map content with the sent entity map value and the other values work the same way as SET. - [`MATCH UPDATE`](#match-update) updates entity map content with new content if match condition is satisfied. -- [`DELETE`](#delete)s the last entity map content for and entity id. +- [`DELETE`](#delete)s the last entity map content for an entity id. - [`EVICT`](#evict) - - Evicts specific entity id and entity map + - Evicts a specific entity id and entity map - Evicts all entities in the entity tree key. **Queries** -- [`SELECT`](#select) the only way to retrieve entity's content. +- [`SELECT`](#select) the only way to retrieve an entity's content. - [`WHERE`](#where-clause) clause is available. - - `WHEN` clause is availbale + - `WHEN` clause is available - [`CHECK`](#check) the only way to verify keys that are encrypted. > ALL DATA STRUCTURES HASHMAPS, HASHSETS AND LIST MUST CONTAIN A `,` AFTER EACH ELEMENT. Example `#{name, ssn,}` is valid but `#{name, ssn}` is not valid. @@ -32,8 +32,8 @@ Creates an entity tree key. * `CREATE ENTITY my_entity` this will create an entity tree key named `my_entity`, in SQL terms it means `CREATE TABLE my_entity`. * `CREATE ENTITY my_entity UNIQUES #{name, ssn,}` the entity tree key named `my_entity` will only allow unique values for the entities keys `name` and `ssn` in its maps. -* `CREATE ENTITY my_entity ENCRYPTS #{pswd,}` the entity tree key named `my_entity` will encrypt the entities keys that are `pswd`. The hashing cost of the encrypt is defined by the environment variable `HASHING_COST`, recommended is between 10 and 14. -* Encryted keys cannot be uniques so `CREATE ENTITY my_entity UNIQUES #{name, ssn, pswd,} ENCRYPTS #{pswd,}` is invalid but `CREATE ENTITY my_entity UNIQUES #{name, ssn,} ENCRYPTS #{pswd,}` is valid. +* `CREATE ENTITY my_entity ENCRYPTS #{pswd,}` the entity tree key named `my_entity` will encrypt the entities keys that are `pswd`. The hashing cost of the encrypt is defined by the environment variable `HASHING_COST`, the recommended is between 10 and 14. +* Encrypted keys cannot be unique so `CREATE ENTITY my_entity UNIQUES #{name, ssn, pswd,} ENCRYPTS #{pswd,}` is invalid but `CREATE ENTITY my_entity UNIQUES #{name, ssn,} ENCRYPTS #{pswd,}` is valid. ### INSERT @@ -51,25 +51,25 @@ Updates the content by replacing the previous entity map in entity tree key `my_ ### UPDATE CONTENT -Updates the content by numerical addition or string concatenation of the previous entity map in entity tree key `my_entity_name` with the entity id `48c7640e-9287-468a-a07c-2fb00da5eaed`. Non numerical or non string value will just be replaced. If key doesn't exist it will be created. +Updates the content by numerical addition or string concatenation of the previous entity map in entity tree key `my_entity_name` with the entity id `48c7640e-9287-468a-a07c-2fb00da5eaed`. Non numerical or non string value will just be replaced. If the key doesn't exist it will be created. * `UPDATE my_entity_name CONTENT {a: -4, b: 32,} INTO 48c7640e-9287-468a-a07c-2fb00da5eaed` this will add `-4` to entity map key `a` and add `32` to entity map key `b` in the current entity map stored in entity id `48c7640e-9287-468a-a07c-2fb00da5eaed`. ### MATCH UPDATE -Similar to SET, but it requires a pre-condition to be satisfied. +Similar to SET, but it requires a precondition to be satisfied. * `MATCH ALL(a == 1, b >= 3, c != \"hello\", d < 7,) UPDATE this_entity SET {a: 123, g: NiL,} INTO d6ca73c0-41ff-4975-8a60-fc4a061ce536` if all conditions defined inside `ALL` are satisfied the set update will happen. - `ALL` is an logical `and` between all conditions, meaning that all of them must be true. - `ANY` is an logical `or` between all conditions, meaning that at least one of them must be true. - **NULL KEYS**, `ALL` returns an error if a null key is present and `ANY` just ignores null keys. - Possible conditions are: - - `==` means equals, so if `a == 100`, this means that the entity map key `a` must equals to `100`. - - `!=` means not equals, so if `a != 100`, this means that the entity map key `a` must not equals to `100`. - - `>=` means greater or equal, so if `a >= 100`, this means that the entity map key `a` must br greater or equals to `100`. - - `<=` means lesser or equal, so if `a <= 100`, this means that the entity map key `a` must be lesser or equals to `100`. - - `>` means greater, so if `a > 100`, this means that the entity map key `a` must be greater than `100`. - - `<` means lesser, so if `a < 100`, this means that the entity map key `a` must be lesser than `100`. + - `==` means equals, so if `a == 100`, this means that the entity map key `a` must equal to `100`. + - `!=` means not equal, so if `a != 100`, this means that the entity map key `a` must not equal to `100`. + - `>=` means greater or equal, so if `a >= 100`, this means that the entity map key `a` must br greater or equal to `100`. + - `<=` means lesser or equal, so if `a <= 100`, this means that the entity map key `a` must be lesser or equal to `100`. + - `>` means greater, so if `a > 100`, this means that the entity map key `a` must be greater than `100`. + - `<` means lesser, so if `a < 100`, this means that the entity map key `a` must be less than `100`. ### DELETE @@ -86,7 +86,7 @@ Removes all occurrences of an entity from the entity tree. It can be just the en ### CHECK -Checks for encrypted key data validity. This transaction only works with keys that are encrypted and it serves as a way to verify if the passed values are `true` of `false` against encrypted data. +Checks for encrypted key data validity. This transaction only works with keys that are encrypted and it serves as a way to verify if the passed values are `true` of `false` against encrypted data. * `CHECK {pswd: "my-password", ssn: 3948453,} FROM my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed` this will check if keys `psdw` and `ssn` from entity id `48c7640e-9287-468a-a07c-2fb00da5eaed` in entity tree key `my_entity_name` have the values `"my-password"` for pswd and `3948453` for ssn. @@ -94,7 +94,7 @@ Checks for encrypted key data validity. This transaction only works with keys th This is the way to query entities from WooriDB. Similar to SQL and SparQL `SELECT`. -Possible `SELECT` combinantions: +Possible `SELECT` combinations: * `SELECT * FROM my_entity_name` selects all entity ids and entity maps for the entity tree key `my_entity_name` with all the possible entities map keys. * `SELECT #{name, last_name, age,} FROM my_entity_name` selects all entity ids and entity maps for the entity tree key `my_entity_name` with only the keys `name, last_name, age` for the entities map. * `SELECT * FROM my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed` selects the entity map containing the entity id `48c7640e-9287-468a-a07c-2fb00da5eaed` from the entity tree key `my_entity_name` with all the possible entities map keys. @@ -102,10 +102,10 @@ Possible `SELECT` combinantions: * `SELECT * FROM my_entity_name IDS IN #{48c7640e-9287-468a-a07c-2fb00da5eaed, 57c7640e-9287-448a-d07c-3db01da5earg, 54k6640e-5687-445a-d07c-5hg61da5earg,}` this will return the entities map containing the entities ids `#{48c7640e-9287-468a-a07c-2fb00da5eaed, 57c7640e-9287-448a-d07c-3db01da5earg, 54k6640e-5687-445a-d07c-5hg61da5earg,}` from entity tree key `my_entity_name`. Keys set is available. * `Select * FROM my_entity ID 0a1b16ed-886c-4c99-97c9-0b977778ec13 WHEN AT 2014-11-28T21:00:09+09:00` this will select the last entity map state for the entity id `0a1b16ed-886c-4c99-97c9-0b977778ec13` in entity tree key `my_entity` at date `2014-11-28`. Requires to use DateTime UTC, for now. * `SELECT * FROM entity_name ID WHEN START 2014-11-28T09:00:09Z END 2014-11-28T21:00:09Z` this will select the all entity map states for the entity id `0a1b16ed-886c-4c99-97c9-0b977778ec13` in entity tree key `my_entity` in the time range starting at `2014-11-28T09:00:09Z` and ending at `2014-11-28T21:00:09Z`. -* `SELECT * FROM my_entity WHERE { ?* my_entity:a ?a, ?* my_entity:c ?c, (== ?a 123),(or (>= ?c 4300.0), (< ?c 6.9),),}` this will select all enitities ids and entities maps from entity tree key `my_entity` that satisfy the where clause. - - `?* my_entity:a ?a` and `?* my_entity:c ?c` define that the entity keys `a` and `c` from entity tree key `my_entity` will receive the attributed value `?a` and `?c` repectively. +* `SELECT * FROM my_entity WHERE { ?* my_entity:a ?a, ?* my_entity:c ?c, (== ?a 123),(or (>= ?c 4300.0), (< ?c 6.9),),}` this will select all entities ids and entities maps from entity tree key `my_entity` that satisfy the where clause. + - `?* my_entity:a ?a` and `?* my_entity:c ?c` define that the entity keys `a` and `c` from entity tree key `my_entity` will receive the attributed value `?a` and `?c` respectively. - `(== ?a 123)` selects all entities which entity map key `a` is equal to `123`. - - `(or (>= ?c 4300.0), (< ?c 6.9),)` selects all entities which entity map key `c` is greater or equal to `4300.0` **or** is smaller than `6.9`. + - `(or (>= ?c 4300.0), (< ?c 6.9),)` selects all entities which entity map key `c` is greater than or equal to `4300.0` **or** is smaller than `6.9`. #### WHERE Clause @@ -141,7 +141,7 @@ Some relation algebra may be implemented: - [x] `Char(char)` contains the type char defined by `'c'`, - [x] `Integer(isize)` contains the type isize, just a number without `.`, -- [x] `String(String)` contains any value passed wuth `"this is a string"`, +- [x] `String(String)` contains any value passed with `"this is a string"`, - [x] `Uuid(Uuid)` contains an `Uuid V4`, - [x] `Float(f64)` contains the type f64, any number containing `.`, - [x] `Boolean(bool)` contains type boolean `true` of `false`, diff --git a/book/src/sec-6-tx.md b/book/src/sec-6-tx.md index eddfac3..f5eb75f 100644 --- a/book/src/sec-6-tx.md +++ b/book/src/sec-6-tx.md @@ -37,7 +37,7 @@ bench_cost_default ... bench: 195,344,338 ns/iter (+/- 8,329,675) ## `INSERT` [INSERT WQL Reference](./sec-4-wql.md#insert) -Inserts a **HashMap** into the entity tree key previously created (`my_entity_name`). This request returns a `Uuid` containing the entity id. +Inserts a **HashMap** into the entity tree key previously created (`my_entity_name`). This request returns a `Uuid` containing the entity id. Example request: ```sql diff --git a/book/src/sec-7-queries.md b/book/src/sec-7-queries.md index 9727017..5077d92 100644 --- a/book/src/sec-7-queries.md +++ b/book/src/sec-7-queries.md @@ -4,13 +4,13 @@ Query is the name of all operations that read the database, like `SELECT, CHECK` > **Reminder** > A comma is required at the end of every data structure representation. -> Ex.: `{a: 123, b: 456,}`, `#{a, b, c,}`, `(a, b, c,)`. +> Ex.: `{a: 123, b: 456,}`, `#{a, b, c,}`, `(a, b, c,)`. > No need for `;` at the end of each expression. ## `CHECK` [CHECK WQL Reference](./sec-4-wql.md#check) -Checks for encrypted data, in entity map, validity. It requires an entity tree name after `FROM` and an entity id as Uuid after `ID`. This transaction only works with keys that are encrypted and it serves to verify if the passed values are `true` of `false` against encrypted data. +Checks for encrypted data, in entity map, validity. It requires an entity tree name after `FROM` and an entity id as Uuid after `ID`. This transaction only works with keys that are encrypted and it serves to verify if the passed values are `true` of `false` against encrypted data. Considering entity tree key `my_entity_name` with entity id `48c7640e-9287-468a-a07c-2fb00da5eaed` with entity map `{pswd: Hash("my-password"), name: "Julia"}` @@ -21,19 +21,19 @@ CHECK {pswd: \"my-password\",} FROM my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed ``` -Example response: +Example response: ```rust {"pswd": true,} ``` ### Exmample 2: -Example request: +Example request: ```sql CHECK {pswd: \"my-password\", ssn: "1234",} FROM my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed ``` -Example response: +Example response: ```rust ( error_type: "CheckNonEncryptedKeys", @@ -42,13 +42,13 @@ Example response: ``` ### Example 3: -Example request: +Example request: ```sql CHECK {pswd: \"your-password\",} FROM my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed ``` -Example response: +Example response: ```rust {"pswd": false,} ``` @@ -61,44 +61,44 @@ This is the way to query entities from WooriDB. Similar to SQL and SparQL `SELEC > `*` and `#{keys...}` can be used in all select modes. ### SELECTing all entity map keys FROM entity tree key: -Same as SQL using the token `*` will defined that all keys in the entity map will be returned. The query `SELECT * FROM entity_name` selects all entity ids and entity maps found inside entity tree key `entity_name`. It is equivalent to SQL's `Select * From table`. +Same as SQL using the token `*` will defined that all keys in the entity map will be returned. The query `SELECT * FROM entity_name` selects all entity ids and entity maps found inside entity tree key `entity_name`. It is equivalent to SQL's `Select * From table`. -Example request: `SELECT * from my_entity_name`. +Example request: `SELECT * from my_entity_name`. Example response: > This query will return a `BTreeMap>` ```rust { - 48c7640e-9287-468a-a07c-2fb00da5eaed: - {a: 123, b: 43.3, c: "hello", d: "world", tx_time: DateTime("2014-11-28T12:00:09Z"),}, - 57c7640e-9287-448a-d07c-3db01da5earg: - {a: 456, b: 73.3, c: "hello", d: "brasil", tx_time: DateTime("2014-11-28T12:00:09Z"),}, - 54k6640e-5687-445a-d07c-5hg61da5earg: + 48c7640e-9287-468a-a07c-2fb00da5eaed: + {a: 123, b: 43.3, c: "hello", d: "world", tx_time: DateTime("2014-11-28T12:00:09Z"),}, + 57c7640e-9287-448a-d07c-3db01da5earg: + {a: 456, b: 73.3, c: "hello", d: "brasil", tx_time: DateTime("2014-11-28T12:00:09Z"),}, + 54k6640e-5687-445a-d07c-5hg61da5earg: {a: 789, b: 93.3, c: "hello", d: "korea", tx_time: DateTime("2014-11-28T12:00:09Z"),}, } ``` ### SELECTing a set of entity map keys FROM entity tree key: -Differently from SQL, WQL requires the keys to be inside a set like `#{a, b, c,}`, which will return only the keys `a, b, c`. It is equivalent to `SELECT a, b, c FROM table`. +Differently from SQL, WQL requires the keys to be inside a set like `#{a, b, c,}`, which will return only the keys `a, b, c`. It is equivalent to `SELECT a, b, c FROM table`. -Example request: `SELECT #{a, b, c,} FROM my_entity_name`. +Example request: `SELECT #{a, b, c,} FROM my_entity_name`. Example response: ```rust { - 48c7640e-9287-468a-a07c-2fb00da5eaed: - {a: 123, b: 43.3, c: "hello",}, - 57c7640e-9287-448a-d07c-3db01da5earg: - {a: 456, b: 73.3, c: "hello",}, - 54k6640e-5687-445a-d07c-5hg61da5earg: + 48c7640e-9287-468a-a07c-2fb00da5eaed: + {a: 123, b: 43.3, c: "hello",}, + 57c7640e-9287-448a-d07c-3db01da5earg: + {a: 456, b: 73.3, c: "hello",}, + 54k6640e-5687-445a-d07c-5hg61da5earg: {a: 789, b: 93.3, c: "hello",}, } ``` ### SELECTing one entity map FROM entity tree key: -Select one entity map (by its ID) from entity tree `my_entity`. By including the key `ID` after the `FROM entity_name` it is possible to select a single entity. The content for `ID`is the entity id's Uuid. It is equivalent to SQL's `Select * From table WHERE id = `. +Select one entity map (by its ID) from entity tree `my_entity`. By including the key `ID` after the `FROM entity_name` it is possible to select a single entity. The content for `ID` is the entity id's Uuid. It is equivalent to SQL's `Select * From table WHERE id = `. -Example request `SELECT * from my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed`. +Example request `SELECT * from my_entity_name ID 48c7640e-9287-468a-a07c-2fb00da5eaed`. Example response: > It will return only the entity map contained inside inside entity id `48c7640e-9287-468a-a07c-2fb00da5eaed`. @@ -107,28 +107,28 @@ Example response: ### SELECTing a set of entities IDs and maps FROM entity tree key: Select a few entities maps (by their IDs) from entity tree `my_entity`. Key `IN` receives a set of Uuids -Example request: +Example request: ```sql SELECT #{a, b, c,} -FROM my_entity_name +FROM my_entity_name IDS IN #{48c7640e-9287-468a-a07c-2fb00da5eaed, 57c7640e-9287-448a-d07c-3db01da5earg} ``` - + Example response: ```rust { - 48c7640e-9287-468a-a07c-2fb00da5eaed: - {a: 123, b: 43.3, c: "hello",}, - 57c7640e-9287-448a-d07c-3db01da5earg: - {a: 456, b: 73.3, c: "hello",}, + 48c7640e-9287-468a-a07c-2fb00da5eaed: + {a: 123, b: 43.3, c: "hello",}, + 57c7640e-9287-448a-d07c-3db01da5earg: + {a: 456, b: 73.3, c: "hello",}, } ``` ### SELECTing the last entity map for entity id at DATETIME FROM entity tree key: -Select an entity on a defined past day using the `WHEN AT` keys. Key `WHEN AT` is the date to search. Time will be discarded. The `ID` field can be used before `WHEN` to define a specific entity id, `IDS IN` is not supported. Date format should be `"2014-11-28T21:00:09+09:00"` or `"2014-11-28T21:00:09Z"`. +Select an entity on a defined past day using the `WHEN AT` keys. Key `WHEN AT` is the date to search. Time will be discarded. The `ID` field can be used before `WHEN` to define a specific entity id, `IDS IN` is not supported. Date format should be `"2014-11-28T21:00:09+09:00"` or `"2014-11-28T21:00:09Z"`. -Example requests: -* `Select * FROM my_entity ID 0a1b16ed-886c-4c99-97c9-0b977778ec13 WHEN AT 2014-11-28T21:00:09+09:00` +Example requests: +* `Select * FROM my_entity ID 0a1b16ed-886c-4c99-97c9-0b977778ec13 WHEN AT 2014-11-28T21:00:09+09:00` * OR `Select #{name,id,} FROM my_entity WHEN AT 2014-11-28T21:00:09Z`. Example response: @@ -138,30 +138,30 @@ Example response: - [ ] Support `IDS IN` ### SELECTing all entities maps BY ID FROM ENTITY between two DATETIME: -Select all occurrences of an entity id from entity tree `entity_name` in a time range. The time range must be on the same day as `WHEN START 2014-11-28T09:00:09Z END 2014-11-28T21:00:09Z`. +Select all occurrences of an entity id from entity tree `entity_name` in a time range. The time range must be on the same day as `WHEN START 2014-11-28T09:00:09Z END 2014-11-28T21:00:09Z`. - Key `WHEN` defines it as a temporal query. - Key `START` is the `DateTime` to start the range query. - Key `END` is the `DateTime` to end the range query. - Same day validation occurs. Returning the error message `"START date and END date should be the same date."`. -- `IDS IN` will not be supported as the wuery is too extensive. +- `IDS IN` will not be supported as the query is too extensive. -Example request: +Example request: ```sql -SELECT #{a, b, c, d} -FROM entity_name -ID 0a1b16ed-886c-4c99-97c9-0b977778ec13 +SELECT #{a, b, c, d} +FROM entity_name +ID 0a1b16ed-886c-4c99-97c9-0b977778ec13 WHEN START 2014-11-28T09:00:09Z END 2014-11-28T21:00:09Z -``` +``` Example response: ```rust { - "2014-11-28T09:00:09Z": + "2014-11-28T09:00:09Z": {a: 34, b: 4.3, c: "hello", d: "Julia",}, - "2014-11-28T13:00:09Z": + "2014-11-28T13:00:09Z": {a: 23, b: -3.3, c: "hello", d: "World",}, - "2014-11-28T19:00:09Z": + "2014-11-28T19:00:09Z": {a: 78, b: 67.3, c: "hello", d: "Julia",}, "2014-11-28T21:00:09Z": {a: 123, b: 43.3, c: "hello", d: "Gasp",}, @@ -172,16 +172,16 @@ Example response: This is probably the most different part in relation to SQL as it is inspired by SparQL and Crux/Datomic datalog. Selects entities ids and maps with positive WHERE clauses. Key `WHERE` receives all clauses inside a `{...}` block. To use `select` with the `where` clause you can use the following expression: -* `SELECT * FROM my_entity WHERE {}` +* `SELECT * FROM my_entity WHERE {}` #### Example 1: Example Request: ```sql -SELECT * FROM test_entity +SELECT * FROM test_entity WHERE { - ?* test_entity:age ?age, - ?* test_entity:race ?race, - (> ?age 25), + ?* test_entity:age ?age, + ?* test_entity:race ?race, + (> ?age 25), (in ?race "Black" "brown"), } ``` @@ -208,9 +208,9 @@ Example response: #### Example 2: Example request: ```sql -SELECT * FROM test_entity +SELECT * FROM test_entity WHERE { - ?* test_entity:age ?age, + ?* test_entity:age ?age, (between ?age 18 27), } ``` @@ -230,4 +230,3 @@ Example response: #### TODOs: - [ ] Support temporality for where clause - diff --git a/book/src/sec-8-history.md b/book/src/sec-8-history.md index 3e7e899..30b4510 100644 --- a/book/src/sec-8-history.md +++ b/book/src/sec-8-history.md @@ -1,11 +1,11 @@ # Entity History -Entity history is one of the main features of WooriDB. It receives an `entity_key` name and an `entity_id` which will return the whole history of `(DateTime, entity_map)` for the `entity_id` in the entity tree for key `entity_key`. This is done by sending a `POST` request to endpoint `:1438/entity-history`. An example request would be `curl -X POST -H "Content-Type: application/wql" :1438/entity-history -d '(entity_key: "entity_tree_key", entity_id: "",)'`. In `release mode` it is necessary to use header `Authorization: Bearer ` for this endpoint. +Entity history is one of the main features of WooriDB. It receives an `entity_key` name and an `entity_id` which will return the whole history of `(DateTime, entity_map)` for the `entity_id` in the entity tree for key `entity_key`. This is done by sending a `POST` request to endpoint `:1438/entity-history`. An example request would be `curl -X POST -H "Content-Type: application/wql" :1438/entity-history -d '(entity_key: "entity_tree_key", entity_id: "",)'`. In `release mode` it is necessary to use header `Authorization: Bearer ` for this endpoint. -Example request: +Example request: ```ron (entity_key: "entity_tree_key", entity_id: "dc3069e7-2a22-4fbc-ae05-f78a807239c0",) -``` +``` Example response: ```rust @@ -45,12 +45,12 @@ Example response: There are two extra parameters that can be used with `entity-history`, they are `start_datetime` and `end_datetime`. Both parameters are optional and if they are present they will define the time limits of the query. `start_datetime` is the beginning of the time range query while `end_datetime` is the ending of the time range query. If we used `start_datetime` and `end_datetime` for the previous example as `curl -X POST -H "Content-Type: application/wql" :1438/entity-history -d '(entity_key: "entity_tree_key", entity_id: "", start_datetime: Some("2021-03-02T05:00:19.816357937Z"), end_datetime: Some("2021-03-02T05:00:19.817189988Z"),)'` we would have the following result: -Example request: +Example request: ```ron ( - entity_key: "entity_tree_key", - entity_id: "dc3069e7-2a22-4fbc-ae05-f78a807239c0", - start_datetime: Some("2021-03-02T05:00:19.816357937Z"), + entity_key: "entity_tree_key", + entity_id: "dc3069e7-2a22-4fbc-ae05-f78a807239c0", + start_datetime: Some("2021-03-02T05:00:19.816357937Z"), end_datetime: Some("2021-03-02T05:00:19.817189988Z"), ) ``` diff --git a/book/src/sec-9-algebra.md b/book/src/sec-9-algebra.md index 4843245..006e2e3 100644 --- a/book/src/sec-9-algebra.md +++ b/book/src/sec-9-algebra.md @@ -14,7 +14,7 @@ This functions are only supported by the following select queries: - `SELECT */#{...} FROM tree_key_name IDS IN #{...}` ## `GROUP BY` -This groups the responses of the select query in the following type `HashMap>>` (for `group by` associated with `order by` the type is `HashMap)>>`). So the query `SELECT * FROM key GROUP BY c`for the following 6 entities: +This groups the responses of the select query in the following type `HashMap>>` (for `group by` associated with `order by` the type is `HashMap)>>`). So the query `SELECT * FROM key GROUP BY c` for the following 6 entities: ```rust {a: 123, b: 12.3,} @@ -61,7 +61,7 @@ Will produce the response: ] ``` -- [ ] [Order By with multiple arguments](https://github.com/naomijub/wooridb/issues/101). The problem here is how to have multiple `.and_then(...)` alter de `partial_cmp`. +- [ ] [Order By with multiple arguments](https://github.com/naomijub/wooridb/issues/101). The problem here is how to have multiple `.and_then(...)` alter the `partial_cmp`. ## `DEDUP`