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
  • Make a new Template
  • Use Template
  • Full code example

Was this helpful?

  1. TEMPLATES

String

Make a new Template

const { Dubnium, Template } = require('dubnium') // require('dubnium') is an alias of require('dubnium').Dubnium
const template = new Template("Hello, {0}")
import { Dubnium, Template } from 'dubnium'
const template = new Template("Hello, {0}", TemplateTypes.STRING)

Use Template

database.create('tag', template.use("World"))

The parameters of this function determine the index's value in the string.

Example: the parameter 0 will be the value of World since they are both at index 0.

Full code example

string_template.js
const { Dubnium, Template } = require('dubnium')
// import { Dubnium, Template } from 'dubnium' // for ESM
const database = new Dubnium('./db', 'txt') // Initialize a database

const template = new Template("Hello, {0}") // Make a new Template

database.create('tag', template.use('World')) // Create a Record based on the Template
PreviousJSONNextSetup

Last updated 1 year ago

Was this helpful?