Dubnium
v3
v3
  • Overview
  • API
    • Initialize
    • Manage
    • Get
    • Edit
    • Search
    • Miscellaneous
    • Middleware
    • Versioning
  • TEMPLATES
    • JSON
    • String
  • EXTENSIONS
    • Setup
    • Create
    • Find
  • OTHER
  • CLI
  • Events
  • Update Log
  • EXTERNAL LINKS
    • Need more help?
    • Report an Issue
Powered by GitBook
On this page
  • 1. Temporarily-Stored Versions
  • Structure
  • 2. File Versions
  • Structure
  • Limit Versions
  • Retroactively limit versions
  • Read A Version
  • Stop Recording Versions
  • Resume Recording

Was this helpful?

  1. API

Versioning

Dubnium has 2 options to save Record versions.

PreviousMiddlewareNextJSON

Last updated 1 year ago

Was this helpful?

1. Temporarily-Stored Versions

Dubnium may create a directory named versions in .dubnium, but will not create files there unless 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)
Paramter
About
Type
Required

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')
Parameter
About
Type
Required

tag

Record tag

String

date

Date of version

String (ISO date)

Alternatively, if you know the index for the version you would like to read (programmatically), you can use readFromIndex

db.versions.readFromIndex('tag', index)
Paramter
About
Type
Required

tag

Record tag

String

index

Index of version

Number

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 })
new file versioning