-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document multi-part ids #119
Open
kriszyp
wants to merge
6
commits into
release_4.3
Choose a base branch
from
multipart-ids
base: release_4.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
42a36a0
Document multi-part ids
kriszyp 7d5e416
More documentation on multipart ids
kriszyp 6c94f6f
Adding missing quotes
jcohen-hdb a56f66f
Update docs/technical-details/reference/resource.md
kriszyp d5850fe
Update docs/technical-details/reference/resource.md
kriszyp 0f7c758
Use URL constructor for example
kriszyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,16 @@ GET /my-resource/?property=value&property2=another-value | |
|
||
Note that only one of the attributes needs to be indexed for this query to execute. | ||
|
||
REST query parameters are designed so that you can easily and safely construct a set of name-value conditions using standard URL encoding. This allows you to easily construct queries in a URL, and also safely include user-provided values in a query. For example, in JavaScript, you can easily construct a query string from an object of conditions: | ||
|
||
```javascript | ||
let conditions = { category: "software", price: 100 } // these values can come from user input and will be safely encoded | ||
let url = `/my-resource/?${new URLSearchParams(conditions)}` | ||
kriszyp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
However, if you want to perform queries beyond basic name-value equality conditions, you can use a more advanced query language syntax that allows for comparison operators, unions, and grouping of conditions: | ||
|
||
### Comparison Operators | ||
|
||
We can also specify different comparators such as less than and greater than queries using [FIQL](https://datatracker.ietf.org/doc/html/draft-nottingham-atompub-fiql-00) syntax. If we want to specify records with an `age` value greater than 20: | ||
|
||
```http | ||
|
@@ -170,6 +180,27 @@ More complex queries can be created by further nesting groups: | |
GET /Product/?price=lt=100|[rating=5&[tag=fast|tag=scalable|tag=efficient]&inStock=true] | ||
``` | ||
|
||
### Multipart primary keys | ||
|
||
For tables with multipart primary keys, the primary key values can be specified in the URL path, separated by slashes. This allows us to perform hierarchical queries. For example, if we added a product: | ||
|
||
```http | ||
PUT /Product/electronics/123 | ||
Content-Type: application/json | ||
|
||
{ "id": ["electronics", "123"], name": "An electronic product" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
``` | ||
We can query for products in the electronics category: | ||
```http | ||
GET /Product/electronics/ | ||
``` | ||
And this can be combined with other query parameters, for example to find products in the electronics category with a price less than 100: | ||
```http | ||
GET /Product/electronics/?price=lt=100 | ||
``` | ||
|
||
See the [Resource API documentation](../technical-details/reference/resource.md) for how these paths are handled as multipart primary keys. | ||
|
||
## Query Calls | ||
|
||
HarperDB has several special query functions that use "call" syntax. These can be included in the query string as its own query entry (separated from other query conditions with an `&`). These include: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
["nested","id]
looks like it's missing a quote at the end.