πŸ“ƒRecords

A record is a single set of data that follows a schema that is stored on the DWN. They're similar to rows in a traditional relational database.

When interfacing the SDK, queries will return records and mutations will alter them.

Record example

{
  "author": "did:ion:alice",
  "contextId": "bafyreigwuhvcybyu4menjqw5k7zygxihbga6w53kpanboxgszok2dyyqui",
  "dataCid": "bafkreifyhrkwiepwhltyjjhwl2lagdist2h6xt67dkdf24epu3rutzo7r4",
  "dataFormat": "text/plain",
  "dataSize": 11,
  "dateCreated": "2023-10-19T03:32:10.488330Z",
  "messageTimestamp": "2023-10-19T03:32:10.488330Z",
  "interface": "Records",
  "method": "Write",
  "protocol": "http://message-protocol.xyz",
  "protocolPath": "message",
  "published": false,
  "recordId": "bafyreigwuhvcybyu4menjqw5k7zygxihbga6w53kpanboxgszok2dyyqui",
  "schema": "http://message-protocol.xyz/schema/message",
  "recipient": "did:ion:bob"
}

Accessing data

Records have several methods available for accessing their data in commonly utilized formats.

  • record.data.text() returns the data as a plain text string.

  • record.data.json() returns the data as a JSON object.

  • record.data.stream() returns the data as a stream. This is useful for handling large files.

Size limits

A record can have a maximum of 1 GB of data stored on it.