Templates

An easy way to keep your JSON records similar!

Make a new Template

const { Dubnium, Template } = require('dubnium') // require('dubnium') is an alias of require('dubnium').Dubnium
const template = new Template({
id:"",
name:"",
password:""
})
Parameter
About
Type
Required

template

The object to base the new Template on.

Object

Use Template

database.create('tag', template.use('123456',"John","password"))

The parameters of this function are what will be set to the value of the keys in order.

Example: the parameterJohn will be the value of namesince they are both in the second position.

Full code example

const { Dubnium, Template } = require('dubnium')
// import { Dubnium, Template } from 'dubnium' // for ESM
const database = new Dubnium('./db','json' /* Templates are JSON only */) // Initialize a database

const template = new Template({ // Make a new Template
id:"",
name:"",
password:""
})

database.create('tag', template.use('123456',"John","password")) // Create a Record based on the Template

Last updated