Skip to content
Adrian Preuß edited this page Jun 13, 2025 · 5 revisions

Installation

npm install --save datastorages

Usage

Import the Datastorages-API in your project:

import Database from 'datastorages';

And set your Database-Type (optional: With their config):

Database.setType(<type>, <config>);

Example for MySQL:

Database.setType(Database.MySQL);

Or with configurations file:

/* With import */
import MyConfig from './config.json' with { type: 'json' };
Database.setConfig(MyConfig );

/* With file */
Database.setConfig('./config.json');

/* Set type without config, because it's already imported */
Database.setType(Database.MySQL);

Or detailled:

Database.setType(Database.MySQL, {
    Hostname:   'localhost',
    Port:       3306,
    Username:   'root',
    password:   '',
    Database:   'test'
});

Clone this wiki locally