Constructor
new Fireproof(blocks, clock, configopt, authCtxopt)
Name | Type | Attributes | Description |
---|---|---|---|
blocks | Blockstore | The block storage instance to use documents and indexes | |
clock | Array.<CID> | The Merkle clock head to use for the Fireproof instance. | |
config | object | <optional> | Optional configuration options for the Fireproof instance. |
authCtx | object | <optional> | Optional authorization context object to use for any authentication checks. |
- Source
Methods
changesSince(eventopt) → {Object.<{rows: Array.<Object>, clock: Array.<CID>}>}
Returns the changes made to the Fireproof instance since the specified event.
Name | Type | Attributes | Description |
---|---|---|---|
event | Array.<CID> | <optional> | The clock head to retrieve changes since. If null or undefined, retrieves all changes. |
- Source
An object containing the rows and the head of the instance's clock.
- Type:
- Object.<{rows: Array.<Object>, clock: Array.<CID>}>
(async) del(id) → {Object.<{id: string, clock: Array.<CID>}>}
Deletes a document from the database
Name | Type | Description |
---|---|---|
id | string | the document ID |
- Source
- The result of deleting the document from the database
- Type:
- Object.<{id: string, clock: Array.<CID>}>
(async) get(key, optsopt) → {Object.<{_id: string, ...doc: Object}>}
Retrieves the document with the specified ID from the database
Name | Type | Attributes | Description |
---|---|---|---|
key | string | the ID of the document to retrieve | |
opts | Object | <optional> | options |
- Source
- the document with the specified ID
- Type:
- Object.<{_id: string, ...doc: Object}>
(async) put(doc) → {Object.<{id: string, clock: Array.<CID>}>}
Adds a new document to the database, or updates an existing document. Returns the ID of the document and the new clock head.
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
doc | Object | the document to be added Properties
|
- Source
- The result of adding the document to the database
- Type:
- Object.<{id: string, clock: Array.<CID>}>
(async) setClock(clock) → {Promise.<void>}
Move the current instance to a new point in time. This triggers a notification to all listeners of the Fireproof instance so they can repaint UI, etc.
Name | Type | Description |
---|---|---|
clock | Array.<CID> | Clock to use for the snapshot. |
- Source
- Type:
- Promise.<void>
snapshot(clock) → {Fireproof}
Returns a snapshot of the current Fireproof instance as a new instance.
Name | Type | Description |
---|---|---|
clock | Array.<CID> | The Merkle clock head to use for the snapshot. |
- Source
A new Fireproof instance representing the snapshot.
- Type:
- Fireproof
toJSON() → {Object}
Renders the Fireproof instance as a JSON object.
- Source
- The JSON representation of the Fireproof instance. Includes clock heads for the database and its indexes.
- Type:
- Object
(static) registerListener(listener) → {function}
Registers a Listener to be called when the Fireproof instance's clock is updated. Recieves live changes from the database after they are committed.
Name | Type | Description |
---|---|---|
listener | function | The listener to be called when the clock is updated. |
- Source
- A function that can be called to unregister the listener.
- Type:
- function