Versioning

Dubnium has 2 options to save Record versions.

1. Temporarily-Stored Versions

Dubnium may create a directory named versions in .dubnium, but will not create files there unless new file versioning is enabled.

Save versions to db.versions.temp. Temporary versions are removed when the process starts. This can be enabled when initializing Dubnium.

const db = new Dubnium('dir', 'txt', { versioning:{ temp:true } })

Structure

{ tag: [ { date: "2023-04-14T17:27:24.930Z", content: 'content 1' } ] }

2. File Versions

Create a new file in .dubnium/versions/{tag_here}. This can be enabled when initializing Dubnium.

const db = new Dubnium('dir', 'txt', { versioning:{ file:true } })

Structure

The files are stored in .dubnium/versions/TAG/DATE and the file contents are identical to the Record.

Limit Versions

When initializing, add max:number to the versioning object to limit the number of stored versions.

const db = new Dubnium('dir', 'txt', { versioning:{ file:true, max:10 } })

Retroactively limit versions

db.versions.setLength(max)
ParamterAboutTypeRequired

max

The new limit

Number

Read A Version

This is only for file versions. To read a temporary version, access it from db.versions.temp

If you know the ISO date for the version you would like to read (programmatically), you can use readFromDate

db.versions.readFromDate('tag', 'date')
ParameterAboutTypeRequired

tag

Record tag

String

date

Date of version

String (ISO date)

Stop Recording Versions

You can stop versioning anytime; the parameters are the same as the initialization.

db.stopVersioning({ temp:true, file:true })

Resume Recording

db.startVersioning({ temp:true, file:true })

Last updated