Below you will find pages that utilize the taxonomy term “node-js”
Posts
Easy Node.js Mysql database table seeder
First, install npm dependencies:
npm i mysql2 @faker-js/faker dotenv Run the script with the command
node ./index.js Don’t forget to add the mysql db credentials to your .env file and of course edit the getSeedQuery function if you want to use it for your own table.
const mysql = require("mysql2"); const { faker } = require("@faker-js/faker"); require("dotenv").config(); function getSeedQuery(amount = 10000) { return Array.from({ length: amount }) .map(() => { const date = faker.
Posts
SyntaxError: Cannot use import statement outside a module
For the secret game I am developing, I needed a database to store User and Profile data. The game’s backend server is developed using Node.js and Typescript, and to simplify connecting to the MySQL database, I wanted to use TypeORM.
TypeORM is awesome. Previously, I had to create the database from scratch and I connected to the database directly and subsequently executed carefully prepared sql queries with parameters. With TypeORM I can specify entities, add columns with specific qualities.