- Modify & run
dump-sequelize-schema.js
.- It currently uses a few
lodash
methods, so be sure to temporarily install them—or if you feel up to it you can rewrite the script so they're not needed. npm i lodash.sortby lodash.pick lodash.omit lodash.mapvalues
- It currently uses a few
- Inspect
sequelize-schema.json
and make sure it appears represent all of your tables, attributes, indexes, constraints, references, etc... - When you are satisfied, copy and rename
sequelize-schema.json
file into amigration-extras/
directory that is next to yourmigrations/
. Name itinitial-sequelize-schema.json
.migration-extras/
- ->
initial-sequelize-schema.json
- ->
migrations/
- (this folder should probably be empty)
- Run
sequelize migration:create
and then copy the contents of2018XXXXXXXXXX-initial-migration.js
into the newly generated migration script. No additional modifications are required if y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code to encrypt data in sequelize fields | |
// We are using ascii85 as a way save on storage. Also, note that | |
// the space delimiter we are using is a bit of an abuse since in | |
// normal cases ascii85 will skip over it, but since we are using | |
// after encoding and before encoding, it shouldn't be an issue. | |
// | |
// Fields are broken down to facilitate unit testing. | |
// | |
// based on code here: http://vancelucas.com/blog/stronger-encryption-and-decryption-in-node-js/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Sequelize = require('sequelize') | |
var sequelize = new Sequelize('sequelize_test', 'root') | |
//Note that the model definition does not have "fullName" | |
var User = sequelize.define('User', { | |
email: Sequelize.STRING, | |
firstName: Sequelize.STRING, | |
lastName: Sequelize.STRING, | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const git = require('nodegit') | |
const fs = require('fs-extra') | |
const { URL } = require('url') | |
const REPO_URL = 'git@github.com:org/path.git' | |
const CLONE_DIR = '/tmp/private-repo-clone-test' | |
;(async () => { | |
await fs.emptyDir(CLONE_DIR) | |
let authAttempted = false | |
await git.Clone.clone(REPO_URL, CLONE_DIR, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require("redis") | |
, subscriber = redis.createClient() | |
, publisher = redis.createClient(); | |
subscriber.on("message", function(channel, message) { | |
console.log("Message '" + message + "' on channel '" + channel + "' arrived!") | |
}); | |
subscriber.subscribe("test"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = mongoose.connect('mongodb://localhost:27017/DB'); | |
// In middleware | |
app.use(function (req, res, next) { | |
// action after response | |
var afterResponse = function() { | |
logger.info({req: req}, "End request"); | |
// any other clean ups |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
array implementation of a binary heap, example usage: | |
// can optionally provide a comparison function, a function for a max | |
// heap is the default if no comparison function is provided | |
var bh = binaryHeap(); | |
bh.push(5); | |
bh.push(34); | |
bh.push(16); | |
var max = bh.pop(); // 34 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// === Arrays | |
var [a, b] = [1, 2]; | |
console.log(a, b); | |
//=> 1 2 | |
// Use from functions, only select from pattern | |
var foo = () => [1, 2, 3]; |
NewerOlder