-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added info on authentication and updated info on creating DIDs * shortened subject * add more info on SSI Service * updates for web5 v0.8.1 * did documents * did documents * new query examples * added example of writing response record
- Loading branch information
1 parent
31bb1ed
commit 30caeb3
Showing
5 changed files
with
102 additions
and
12 deletions.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Shows how to use filters to query DWN for specific records | ||
----- | ||
|
||
Here are the properties you can use to filter your record query, along with explanations and examples for each. | ||
|
||
| Property | Value | Example | | ||
| ----------- | ---------- | ----------- | | ||
| **`recipient`** | Recipient DID of message | "did:example:alice" | | ||
| **`protocol`** | The URI of the protocol bucket in which to query | "example.com" | | ||
| **`protocolPath`** | Records under a protocol path across all context IDs | "example" | | ||
| **`contextId`** | `recordId` of a root record of a protocol | "bafyreianzpmhbgcgam5mys722vnsiuwn..." | | ||
| **`schema`** | The URI of the schema bucket in which to query | "https<span>://</span>schema.org/Message" | | ||
| **`recordId`** | Property contains the message recordId | "aa36ec55-c59b-4f20-8143-10f74aac696d" | | ||
| **`parentId`** | `recordId` of the parent record in a protocol | "iadsfdreianzpmasdffcgam5mys722vnd..." | | ||
| **`dataFormat`** | The IANA string for the data format to filter | "application/json" | | ||
| **`dateCreated`** | Date the record was created | "2023-04-30T22:49:37.713976Z" | | ||
|
||
Examples: | ||
|
||
Filter by parentId | ||
This snippet queries the DWN for records that have a parent record with a specific record ID: | ||
|
||
const response = await web5.dwn.records.query({ | ||
message: { | ||
filter: { | ||
parentId: 'bafyreianzpmhbgcgam5mys722vnsiuwn7y4ek6kjeyjptttquasw4hge2m', | ||
}, | ||
}, | ||
}); | ||
|
||
|
||
Filter by protocol and protocolPath | ||
assuming playlist and video records have been created using this protocol, the following snippet demonstrates how to query for video records that match the protocol: | ||
|
||
const { records } = await web5.dwn.records.query({ | ||
message: { | ||
filter: { | ||
protocol: 'https://playlist.org/protocol', | ||
protocolPath: 'playlist/video' | ||
}, | ||
}, | ||
}); |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Shows how to sort query results of DWN records and protocols | ||
----- | ||
|
||
Query results can be sorted via the dateSort field. Valid values for dateSort are: | ||
|
||
* createdAscending - sorts by dateCreated in ascending order | ||
* createdDescending - sorts by dateCreated in descending order | ||
* publshedAscending - sorts by datePublished in ascending order | ||
* publishedDescending- sorts by datePublished in descending order | ||
|
||
|
||
//Ascending Order - queries for records with a plain text data format, and returns them in ascending order by the date they were published: | ||
const response = await web5.dwn.records.query({ | ||
message: { | ||
filter: { | ||
dataFormat: 'text/plain', | ||
}, | ||
dateSort: 'publishedAscending', | ||
}, | ||
}); | ||
|
||
|
||
//Descending Order - queries for protocols with a certain URL, and returns them in descending order by the date they were created. | ||
const { protocols } = await web5.dwn.protocols.query({ | ||
message: { | ||
filter: { | ||
protocol: 'http://social-media.xyz', | ||
}, | ||
dateSort: 'createdDescending' | ||
}, | ||
}); |