Skip to content

Commit a78634c

Browse files
committed
Run prettier fix
1 parent 7c7207a commit a78634c

File tree

5 files changed

+114
-79
lines changed

5 files changed

+114
-79
lines changed

docs/developers/rest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,4 @@ PUT /my-resource/33/image
400400
Content-Type: image/gif
401401
402402
...image data...
403-
```
403+
```

versioned_docs/version-4.2/developers/rest.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ HarperDB has several special query functions that use "call" syntax. These can b
128128

129129
This allows you to specify which properties should be included in the responses. This takes several forms:
130130

131-
* `?select(property)`: This will return the values of the specified property directly in the response (will not be put in an object).
132-
* `?select(property1,property2)`: This returns the records as objects, but limited to the specified properties.
133-
* `?select([property1,property2,...])`: This returns the records as arrays of the property values in the specified properties.
134-
* `?select(property1,)`: This can be used to specify that objects should be returned with the single specified property.
131+
- `?select(property)`: This will return the values of the specified property directly in the response (will not be put in an object).
132+
- `?select(property1,property2)`: This returns the records as objects, but limited to the specified properties.
133+
- `?select([property1,property2,...])`: This returns the records as arrays of the property values in the specified properties.
134+
- `?select(property1,)`: This can be used to specify that objects should be returned with the single specified property.
135135

136136
To get a list of product names with a category of software:
137137

versioned_docs/version-4.3/developers/rest.md

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ The comparison operators include standard FIQL operators, `lt` (less than), `le`
122122
GET /Product/?category=software&price=gt=100&price=lt=200
123123
```
124124

125-
Comparison operators can also be used on Date fields, however, we have to ensure that the date format is properly escaped. For example, if we are looking for a listing date greater than `2017-03-08T09:00:00.000Z` we must escape the colons as `%3A`:
125+
Comparison operators can also be used on Date fields, however, we have to ensure that the date format is properly escaped. For example, if we are looking for a listing date greater than `2017-03-08T09:00:00.000Z` we must escape the colons as `%3A`:
126126

127127
```
128128
GET /Product/?listDate=gt=2017-03-08T09%3A30%3A00.000Z
@@ -137,38 +137,49 @@ GET /Product/?name==Keyboard*
137137
Note that some HTTP clients may be overly aggressive in encoding query parameters, and you may need to disable extra encoding of query parameters, to ensure operators are passed through without manipulation.
138138

139139
Here is a full list of the supported FIQL-style operators/comparators:
140-
* `==`: equal
141-
* `=lt=`: less than
142-
* `=le=`: less than or equal
143-
* `=gt=`: greater than
144-
* `=ge=`: greater than or equal
145-
* `=ne=`, !=: not equal
146-
* `=ct=`: contains the value (for strings)
147-
* `=sw=`, `==<value>*`: starts with the value (for strings)
148-
* `=ew=`: ends with the value (for strings)
149-
* `=`, `===`: strict equality (no type conversion)
150-
* `!==`: strict inequality (no type conversion)
140+
141+
- `==`: equal
142+
- `=lt=`: less than
143+
- `=le=`: less than or equal
144+
- `=gt=`: greater than
145+
- `=ge=`: greater than or equal
146+
- `=ne=`, !=: not equal
147+
- `=ct=`: contains the value (for strings)
148+
- `=sw=`, `==<value>*`: starts with the value (for strings)
149+
- `=ew=`: ends with the value (for strings)
150+
- `=`, `===`: strict equality (no type conversion)
151+
- `!==`: strict inequality (no type conversion)
151152

152153
### Unions
154+
153155
Conditions can also be applied with `OR` logic, returning the union of records that match either condition. This can be specified by using the `|` operator instead of `&`. For example, to return any product a rating of `5` _or_ a `featured` attribute that is `true`, we could write:
156+
154157
```http
155158
GET /Product/?rating=5|featured=true
156159
```
157160

158161
### Grouping of Operators
162+
159163
Multiple conditions with different operators can be combined with grouping of conditions to indicate the order of operation. Grouping conditions can be done with parenthesis, with standard grouping conventions as used in query and mathematical expressions. For example, a query to find products with a rating of 5 OR a price between 100 and 200 could be written:
164+
160165
```http
161166
GET /Product/?rating=5|(price=gt=100&price=lt=200)
162167
```
168+
163169
Grouping conditions can also be done with square brackets, which function the same as parenthesis for grouping conditions. The advantage of using square brackets is that you can include user provided values that might have parenthesis in them, and use standard URI component encoding functionality, which will safely escape/encode square brackets, but not parenthesis. For example, if we were constructing a query for products with a rating of a 5 and matching one of a set of user provided tags, a query could be built like:
170+
164171
```http
165172
GET /Product/?rating=5&[tag=fast|tag=scalable|tag=efficient]
166173
```
174+
167175
And the tags could be safely generated from user inputs in a tag array like:
176+
168177
```javascript
169-
let url = `/Product/?rating=5[${tags.map(encodeURIComponent).join('|')}]`
178+
let url = `/Product/?rating=5[${tags.map(encodeURIComponent).join('|')}]`;
170179
```
180+
171181
More complex queries can be created by further nesting groups:
182+
172183
```http
173184
GET /Product/?price=lt=100|[rating=5&[tag=fast|tag=scalable|tag=efficient]&inStock=true]
174185
```
@@ -181,11 +192,11 @@ HarperDB has several special query functions that use "call" syntax. These can b
181192

182193
This function allows you to specify which properties should be included in the responses. This takes several forms:
183194

184-
* `?select(property)`: This will return the values of the specified property directly in the response (will not be put in an object).
185-
* `?select(property1,property2)`: This returns the records as objects, but limited to the specified properties.
186-
* `?select([property1,property2,...])`: This returns the records as arrays of the property values in the specified properties.
187-
* `?select(property1,)`: This can be used to specify that objects should be returned with the single specified property.
188-
* `?select(property{subProperty1,subProperty2{subSubProperty,..}},...)`: This can be used to specify which sub-properties should be included in nested objects and joined/references records.
195+
- `?select(property)`: This will return the values of the specified property directly in the response (will not be put in an object).
196+
- `?select(property1,property2)`: This returns the records as objects, but limited to the specified properties.
197+
- `?select([property1,property2,...])`: This returns the records as arrays of the property values in the specified properties.
198+
- `?select(property1,)`: This can be used to specify that objects should be returned with the single specified property.
199+
- `?select(property{subProperty1,subProperty2{subSubProperty,..}},...)`: This can be used to specify which sub-properties should be included in nested objects and joined/references records.
189200

190201
To get a list of product names with a category of software:
191202

@@ -208,19 +219,25 @@ GET /Product/?rating=gt=3&inStock=true&select(rating,name)&limit(20)
208219
This function allows you to indicate the sort order for the returned results. The argument for `sort()` is one or more properties that should be used to sort. If the property is prefixed with '+' or no prefix, the sort will be performed in ascending order by the indicated attribute/property. If the property is prefixed with '-', it will be sorted in descending order. If the multiple properties are specified, the sort will be performed on the first property, and for records with the same value for that property, the next property will be used to break the tie and sort results. This tie breaking will continue through any provided properties.
209220

210221
For example, to sort by product name (in ascending order):
222+
211223
```http
212224
GET /Product?rating=gt=3&sort(+name)
213225
```
226+
214227
To sort by rating in ascending order, then by price in descending order for products with the same rating:
228+
215229
```http
216230
GET /Product?sort(+rating,-price)
217231
```
218232

219233
# Relationships
234+
220235
HarperDB supports relationships in its data models, allowing for tables to define a relationship with data from other tables (or even itself) through foreign keys. These relationships can be one-to-many, many-to-one, or many-to-many (and even with ordered relationships). These relationships are defined in the schema, and then can easily be queried through chained attributes that act as "join" queries, allowing related attributes to referenced in conditions and selected for returned results.
221236

222237
## Chained Attributes and Joins
238+
223239
To support relationships and hierarchical data structures, in addition to querying on top-level attributes, you can also query on chained attributes. Most importantly, this provides HarperDB's "join" functionality, allowing related tables to be queried and joined in the results. Chained properties are specified by using dot syntax. In order to effectively leverage join functionality, you need to define a relationship in your schema:
240+
224241
```graphql
225242
type Product @table @export {
226243
id: ID @primaryKey
@@ -234,35 +251,47 @@ type Brand @table @export {
234251
products: [Product] @relationship(to: "brandId")
235252
}
236253
```
254+
237255
And then you could query a product by brand name:
256+
238257
```http
239258
GET /Product/?brand.name=Microsoft
240259
```
260+
241261
This will query for products for which the `brandId` references a `Brand` record with a `name` of `"Microsoft"`.
242262

243263
The `brand` attribute in `Product` is a "computed" attribute from the foreign key (`brandId`), for the many-to-one relationship to the `Brand`. In the schema above, we also defined the reverse one-to-many relationship from a `Brand` to a `Product`, and we could likewise query that:
264+
244265
```http
245266
GET /Brand/?products.name=Keyboard
246267
```
268+
247269
This would return any `Brand` with at least one product with a name `"Keyboard"`. Note, that both of these queries are effectively acting as an "INNER JOIN".
248270

249271
### Chained/Nested Select
272+
250273
Computed relationship attributes are not included by default in query results. However, we can include them by specifying them in a select:
274+
251275
```http
252276
GET /Product/?brand.name=Microsoft&select(name,brand)
253277
```
278+
254279
We can also do a "nested" select and specify which sub-attributes to include. For example, if we only wanted to include the name property from the brand, we could do so:
280+
255281
```http
256282
GET /Product/?brand.name=Microsoft&select(name,brand{name})
257283
```
284+
258285
Or to specify multiple sub-attributes, we can comma delimit them. Note that selects can "join" to another table without any constraint/filter on the related/joined table:
286+
259287
```http
260288
GET /Product/?name=Keyboard&select(name,brand{name,id})
261289
```
262-
When selecting properties from a related table without any constraints on the related table, this effectively acts like a "LEFT JOIN" and will omit the `brand` property if the brandId is `null` or references a non-existent brand.
263290

291+
When selecting properties from a related table without any constraints on the related table, this effectively acts like a "LEFT JOIN" and will omit the `brand` property if the brandId is `null` or references a non-existent brand.
264292

265293
### Many-to-many Relationships (Array of Foreign Keys)
294+
266295
Many-to-many relationships are also supported, and can easily be created using an array of foreign key values, without requiring the traditional use of a junction table. This can be done by simply creating a relationship on an array-typed property that references a local array of foreign keys. For example, we could create a relationship to the resellers of a product (each product can have multiple resellers, each )
267296

268297
```graphql
@@ -278,11 +307,15 @@ type Reseller @table {
278307
...
279308
}
280309
```
310+
281311
The product record can then hold an array of the reseller ids. When the `reseller` property is accessed (either through code or through select, conditions), the array of ids is resolved to an array of reseller records. We can also query through the resellers relationships like with the other relationships. For example, to query the products that are available through the "Cool Shop":
312+
282313
```http
283314
GET /Product/?resellers.name=Cool Shop&select(id,name,resellers{name,id})
284315
```
316+
285317
One of the benefits of using an array of foreign key values is that the this can be manipulated using standard array methods (in JavaScript), and the array can dictate an order to keys and therefore to the resulting records. For example, you may wish to define a specific order to the resellers and how they are listed (which comes first, last):
318+
286319
```http
287320
PUT /Product/123
288321
Content-Type: application/json
@@ -292,14 +325,16 @@ Content-Type: application/json
292325
```
293326

294327
### Type Conversion
328+
295329
Queries parameters are simply text, so there are several features for converting parameter values to properly typed values for performing correct searches. For the FIQL comparators, which includes `==`, `!=`, `=gt=`, `=lt=`, `=ge=`, `=gt=`, the parser will perform type conversion, according to the following rules:
296-
* `name==null`: Will convert the value to `null` for searching.
297-
* `name==123`: Will convert the value to a number _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
298-
* `name==true`: Will convert the value to a boolean _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
299-
* `name==number:123`: Will explicitly convert the value after "number:" to a number.
300-
* `name==boolean:true`: Will explicitly convert the value after "boolean:" to a boolean.
301-
* `name==string:some%20text`: Will explicitly keep the value after "string:" as a string (and perform URL component decoding)
302-
* `name==date:2024-01-05T20%3A07%3A27.955Z`: Will explicitly convert the value after "date:" to a Date object.
330+
331+
- `name==null`: Will convert the value to `null` for searching.
332+
- `name==123`: Will convert the value to a number _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
333+
- `name==true`: Will convert the value to a boolean _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
334+
- `name==number:123`: Will explicitly convert the value after "number:" to a number.
335+
- `name==boolean:true`: Will explicitly convert the value after "boolean:" to a boolean.
336+
- `name==string:some%20text`: Will explicitly keep the value after "string:" as a string (and perform URL component decoding)
337+
- `name==date:2024-01-05T20%3A07%3A27.955Z`: Will explicitly convert the value after "date:" to a Date object.
303338

304339
If the attribute specifies a type (like `Float`) in the schema definition, the value will always be converted to the specified type before searching.
305340

versioned_docs/version-4.4/developers/rest.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,17 @@ Note that some HTTP clients may be overly aggressive in encoding query parameter
150150

151151
Here is a full list of the supported FIQL-style operators/comparators:
152152

153-
* `==`: equal
154-
* `=lt=`: less than
155-
* `=le=`: less than or equal
156-
* `=gt=`: greater than
157-
* `=ge=`: greater than or equal
158-
* `=ne=`, !=: not equal
159-
* `=ct=`: contains the value (for strings)
160-
* `=sw=`, `==<value>*`: starts with the value (for strings)
161-
* `=ew=`: ends with the value (for strings)
162-
* `=`, `===`: strict equality (no type conversion)
163-
* `!==`: strict inequality (no type conversion)
153+
- `==`: equal
154+
- `=lt=`: less than
155+
- `=le=`: less than or equal
156+
- `=gt=`: greater than
157+
- `=ge=`: greater than or equal
158+
- `=ne=`, !=: not equal
159+
- `=ct=`: contains the value (for strings)
160+
- `=sw=`, `==<value>*`: starts with the value (for strings)
161+
- `=ew=`: ends with the value (for strings)
162+
- `=`, `===`: strict equality (no type conversion)
163+
- `!==`: strict inequality (no type conversion)
164164

165165
#### Unions
166166

@@ -187,7 +187,7 @@ GET /Product/?rating=5&[tag=fast|tag=scalable|tag=efficient]
187187
And the tags could be safely generated from user inputs in a tag array like:
188188

189189
```javascript
190-
let url = `/Product/?rating=5[${tags.map(encodeURIComponent).join('|')}]`
190+
let url = `/Product/?rating=5[${tags.map(encodeURIComponent).join('|')}]`;
191191
```
192192

193193
More complex queries can be created by further nesting groups:
@@ -204,11 +204,11 @@ Harper has several special query functions that use "call" syntax. These can be
204204

205205
This function allows you to specify which properties should be included in the responses. This takes several forms:
206206

207-
* `?select(property)`: This will return the values of the specified property directly in the response (will not be put in an object).
208-
* `?select(property1,property2)`: This returns the records as objects, but limited to the specified properties.
209-
* `?select([property1,property2,...])`: This returns the records as arrays of the property values in the specified properties.
210-
* `?select(property1,)`: This can be used to specify that objects should be returned with the single specified property.
211-
* `?select(property{subProperty1,subProperty2{subSubProperty,..}},...)`: This can be used to specify which sub-properties should be included in nested objects and joined/references records.
207+
- `?select(property)`: This will return the values of the specified property directly in the response (will not be put in an object).
208+
- `?select(property1,property2)`: This returns the records as objects, but limited to the specified properties.
209+
- `?select([property1,property2,...])`: This returns the records as arrays of the property values in the specified properties.
210+
- `?select(property1,)`: This can be used to specify that objects should be returned with the single specified property.
211+
- `?select(property{subProperty1,subProperty2{subSubProperty,..}},...)`: This can be used to specify which sub-properties should be included in nested objects and joined/references records.
212212

213213
To get a list of product names with a category of software:
214214

@@ -340,13 +340,13 @@ Content-Type: application/json
340340

341341
Queries parameters are simply text, so there are several features for converting parameter values to properly typed values for performing correct searches. For the FIQL comparators, which includes `==`, `!=`, `=gt=`, `=lt=`, `=ge=`, `=gt=`, the parser will perform type conversion, according to the following rules:
342342

343-
* `name==null`: Will convert the value to `null` for searching.
344-
* `name==123`: Will convert the value to a number _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
345-
* `name==true`: Will convert the value to a boolean _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
346-
* `name==number:123`: Will explicitly convert the value after "number:" to a number.
347-
* `name==boolean:true`: Will explicitly convert the value after "boolean:" to a boolean.
348-
* `name==string:some%20text`: Will explicitly keep the value after "string:" as a string (and perform URL component decoding)
349-
* `name==date:2024-01-05T20%3A07%3A27.955Z`: Will explicitly convert the value after "date:" to a Date object.
343+
- `name==null`: Will convert the value to `null` for searching.
344+
- `name==123`: Will convert the value to a number _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
345+
- `name==true`: Will convert the value to a boolean _if_ the attribute is untyped (there is no type specified in a GraphQL schema, or the type is specified to be `Any`).
346+
- `name==number:123`: Will explicitly convert the value after "number:" to a number.
347+
- `name==boolean:true`: Will explicitly convert the value after "boolean:" to a boolean.
348+
- `name==string:some%20text`: Will explicitly keep the value after "string:" as a string (and perform URL component decoding)
349+
- `name==date:2024-01-05T20%3A07%3A27.955Z`: Will explicitly convert the value after "date:" to a Date object.
350350

351351
If the attribute specifies a type (like `Float`) in the schema definition, the value will always be converted to the specified type before searching.
352352

0 commit comments

Comments
 (0)