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
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
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
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
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
"createRecordWithoutStore": "// this creates a record, but does not store it in the user's local DWN\n const { record } = await web5.dwn.records.create({\n //highlight-start\n store: false,\n //highlight-end\n data: 'Hello again, World!',\n message: {\n recipient: 'did:example:alice',\n dataFormat: 'text/plain',\n },\n });",
"createRecordAndSend": "// this creates a record and stores it in the user's local DWN\n const { record } = await web5.dwn.records.create({\n data: 'Hello World!',\n message: {\n dataFormat: 'text/plain',\n },\n });\n\n /*\n send the record to the user's remote DWNs. Only needed\n if it's a record that cannot wait for sync to occur.\n */\n const { status: myDidStatus } = await record.send(myDid);\n\n // send the newly generated record to Bob's DWNs\n const { status: bobStatus } = await record.send(bobDid);",
"sortQueriedRecordsByDate": "// Sorting records by dateCreated in ascending order\n const response = await web5.dwn.records.query({\n message: {\n filter: {\n dataFormat: 'text/plain',\n },\n //highlight-start\n dateSort: 'createdAscending'\n //highlight-end\n }\n });",
"readRecordFromId": "// Reads the indicated record from the user's DWNs\nlet { record } = await web5.dwn.records.read({\n message: {\n filter: {\n recordId: recordId\n}\n}\n});\n\n// assuming the record has a text payload\nconst text = await record.data.text();",
"readRecordByIdFromDid": "// Reads the indicated record from Bob's DWNs\nconst { record } = await web5.dwn.records.read({\n //highlight-start\n from: bobDid,\n //highlight-end\n message: {\n filter:{\n recordId: recordId\n}\n}\n});\n\n// assuming the record is a json payload\nconst data = await record.data.json();",
"sortQueriedRecordsByDate": "// Sorting records by dateCreated in ascending order\n const response = await web5.dwn.records.query({\n message: {\n filter: {\n dataFormat: 'text/plain',\n },\n //highlight-start\n dateSort: 'createdAscending',\n //highlight-end\n },\n });",
"readRecordFromId": "// Reads the indicated record from the user's DWNs\n let { record } = await web5.dwn.records.read({\nmessage: {\nfilter: {\nrecordId: recordId,\n },\n },\n});\n\n// assuming the record has a text payload\n const text = await record.data.text();",
"readRecordByIdFromDid": "// Reads the indicated record from Bob's DWNs\n const { record } = await web5.dwn.records.read({\n//highlight-start\nfrom: bobDid,\n//highlight-end\nmessage: {\nfilter:{\nrecordId: recordId,\n },\n },\n});\n\n// assuming the record is a json payload\n const data = await record.data.json();",
"deleteFromLocalDWN": "//Query records with plain text data format\nconst response = await web5.dwn.records.query({\n message: {\n filter: {\n recordId: recordId,\n },\n },\n});\n\n// Grab the first indexed record\nconst record = response.records[0];\n\n// Delete the record\nconst deleteResult = await record.delete();",
"deleteFromLocalDWN": "//Query records with plain text data format\n const response = await web5.dwn.records.query({\nmessage: {\nfilter: {\nrecordId: recordId,\n},\n},\n});\n\n// Grab the first indexed record\n const record = response.records[0];\n\n// Delete the record\n const deleteResult = await web5.dwn.records.delete({\n message: {\n recordId: recordId\n },\n });",
"createRecordWithDatePublished": "// Create a new Date instance for tomorrow\nconst today = new Date();\nconst tomorrow = new Date(today);\ntomorrow.setDate(today.getDate() + 1);\n\n// Format the date and time in YYYY-MM-DDThh:mm:ss.ssssssZ format\nconst formattedDate = tomorrow.toISOString().replace(/\\.\\d{3}Z$/, '.000000Z');\n\n// Create a record today to be published tomorrow\nconst { record } = await web5.dwn.records.create({\n data: \"This record will be created now and published tomorrow\",\n message: {\n dataFormat: \"text/plain\",\n //highlight-start\n published: true,\n datePublished: formattedDate\n //highlight-end\n },\n});",
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