πŸ†”
ID++ SDK Docs
  • πŸ†”Introduction
  • ❓Why use the ID++ SDK?
  • πŸ’‘Key concepts
    • ℹ️Decentralized Web Node (DWN)
    • ℹ️Decentralized identities (DID)
    • ℹ️Schemas
    • ℹ️Records
  • πŸ€“Reference
    • βš™οΈInstallation
    • βš™οΈConfiguration
    • βš™οΈInitialization
    • πŸ“ƒRecords
      • πŸ“–Queries
        • πŸ“‘How to query records
      • βš’οΈCRUD Operations
        • πŸ†•Create a record
        • πŸ“šRead a record
        • πŸ“‘Update a record
        • ❌Delete a record
    • πŸ›‘οΈVerifiable Credentials
      • πŸ’³Credentials
      • πŸ“œPresentations
  • πŸ—ΊοΈGuides
    • πŸ“Handling files
    • πŸš€Sharing records
Powered by GitBook
On this page
  1. Reference
  2. Records
  3. Queries

How to query records

PreviousQueriesNextCRUD Operations

Last updated 1 year ago

Returns a list of all records added to the . The records are returned in sorted order and can be filtered by as well.

const queryParams = {
  message: {
    author: 'did:ion:alice', // optional
    filter: {
      protocol,
      schema,
      dataFormat,
    },
    dateSort: 'createdDescending'
}};

const { records, status } = await sdk.dwn.records.query(queryParams);

if (status.code !== 200) {
  console.error('Failed to query...', status);
  return;
}

for (let record of records) {
  const { author, note } = await record.data.json();
  console.info(`${author.substr(0, 22)}... ${note}`);
}

Filtering records

// message filtering options
message: {
  filter: {
    recordId: <record.id>,
    protocol: <protocol.name>,
    schema: <schema.type>,
  },
}
πŸ€“
πŸ“ƒ
πŸ“–
πŸ“‘
DWN
schema