Document
Application data records
Overview
Dash Platform is based on document-oriented database concepts and uses related terminology. In short, JSON documents are stored into document collections which can then be fetched back using a query language similar to common document-oriented databases like MongoDB, CouchDB, or Firebase.
Documents are defined in an application's Data Contract and represent the structure of application-specific data. Each document consists of one or more fields and the indices necessary to support querying.
Work in Progress
This document is an work in progress. Details may be missing or incomplete and are subject to change.
Details
Base Fields
Dash Platform Protocol (DPP) defines a set of base fields that must be present in all documents. For the js-dpp
reference implementation, the base fields shown below are defined in the document base schema.
Field Name | Description |
---|---|
$id | Document ID |
$type | Type of document (must match one of the document types defined in the data contract) |
$dataContractId | ID of the data contract that defines this document |
$ownerId | Identity submitting the document |
$revision | Document revision (=> 1) |
$createdAt | (Optional) Time (in milliseconds) the document was created |
$updatedAt | (Optional) Time (in milliseconds) the document was updated |
Timestamp fields
Note: The
$createdAt
and$updatedAt
fields will only be present in documents that add them to the list of required properties.
Data Contract Fields
Each application defines its own fields via document definitions in its data contract. Details of the DPNS data contract documents are described below as an example. This contract defines two document types (preorder
and domain
) and provides the functionality described in the Name Service explanation.
Document Name | Field Name | Data Type |
---|---|---|
preorder | saltedDomainHash | string |
--- | --- | --- |
domain | nameHash | string |
domain | label | string |
domain | normalizedLabel | string |
domain | normalizedParentvDomainName | string |
domain | preorderSalt | string |
domain | records | object |
Document Submission
Once a document has been created, it must be encapsulated in a State Transition to be sent to the platform. The structure of a document state transition is shown below. For additional details, see the State Transition explanation.
Field Name | Description |
---|---|
protocolVersion | Dash Platform Protocol version (currently 0 ) |
type | State transition type (1 for documents) |
ownerId | Identity submitting the document(s) |
transitions | Document create , replace , or delete transitions (up to 10 objects) |
signaturePublicKeyId | The id of the identity public key that signed the state transition |
signature | Signature of state transition data |
Example Document
The following example shows the structure of a DPNS domain
document as output from the document .toJSON()
method. Note the $
prefix indicating the base fields.
{
'$id': 'GbMwuXdxzN3BB9efMgLPRhbbqCA5jnyfka2jnbyvGyih',
'$type': 'domain',
'$dataContractId': '295xRRRMGYyAruG39XdAibaU9jMAzxhknkkAxFE7uVkW',
'$ownerId': 'HjRuBghdteSmiN8w1VvGe9VHShdAxgt329xBHNQhyUGL',
'$revision': 1,
label: 'testName1234',
records: {
dashIdentity: 'HjRuBghdteSmiN8w1VvGe9VHShdAxgt329xBHNQhyUGL'
},
nameHash: '5620938ed72967fa06cfd9ebcd3bf9e5a5abf366563f5ea1f1874a531e7d78e75500',
preorderSalt: 'ya9GK3VwCeLxyAS9jnQX7WTkGcXMJV96mX',
normalizedLabel: 'testname1234',
normalizedParentDomainName: 'dash'
}
Updated about 4 years ago