Skip to content

Instantly share code, notes, and snippets.

View NigelEarle's full-sized avatar

Nigel Earle NigelEarle

  • NWRE Development
  • San Diego, CA
View GitHub Profile
@NigelEarle
NigelEarle / Knex-Setup.md
Last active May 4, 2024 13:36
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
@NigelEarle
NigelEarle / cluster.js
Created November 9, 2017 17:20
Node.js cluster
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);
// Fork workers.
for (let i = 0; i < numCPUs; i++) {
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active March 23, 2024 09:04
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables