Synchronization

Overwrite from another Record

await db.get('tag').syncWith('_tag')
Parameter
About
Type
Required

_tag

The tag of the Record you want to get the content from.

String

Watch a File

Watch the record for changes and emit events when the record is modified. The watcher will continue to run until you call the stop function returned by this method.

const { watcher, stop } = db.get('tag').watch()

for await (const event of watcher) {
       console.log(`Event type: ${event.eventType}`);
        console.log(`Filename: ${event.filename}`);
}

stop() // Stop watching

Duplicate Entire Database

Copy all records from the current database to a new target directory, creating a new Dubnium instance for the target directory and writing each record's data to the corresponding file in the target directory.

db.copyTo('path')
Parameter
About
Type
Required

path

Path to new dir

String

Replication / Continuous Sync

Set up real-time replication of records to a new target directory by listening for record creation, updates, and deletions in the current database and applying those changes to the target directory. This method creates a new Dubnium instance for the target directory and registers event listeners for 'create', 'edit', and 'delete' events emitted by the current database. When a record is created, edited, or deleted in the current database, the corresponding event listener will be triggered, and it will perform the same operation on the target database to keep it in sync. The method returns a function that can be called to stop the replication by removing the event listeners.

Parameter
About
Type
Required

path

Path to new dir

String

Stop Replication

Flush Replication Queue

Replication Status

Last updated