Info |
---|
Node.JS can access external data-sources but it should be used wisely. A Node.JS application runs in the context of the front end. Frontend components should NOT be directly accessing data-sources. However, they can access some kind of local-storage system for the handling of temporary data, but even then it should be done with care and a lot of thought in terms of the long term scalability. |
Using the File System
Use the module "fs", visit https://nodejs.org/docs/latest-v13.x/api/fs.html
Code Block |
---|
|
const fs = require("fs"); |
Using a database
Use the module that matches the database you want to access, visit https://expressjs.com/en/guide/database-integration.html
Code Block |
---|
|
var mysql = require('mysql')
var connection = mysql.createConnection({
host: 'localhost',
user: 'dbuser',
password: 's3kreee7',
database: 'my_db'
}) |