Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo
Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo
<table id="cardTable" class="tablesorter"> | |
<thead> | |
<!-- Don't need this --> | |
</thead> | |
<tr id="card_1234" class="card-row" data-id="1234" data-name="card-name" data-elems="water fire"> | |
<td> | |
<span> | |
<!-- don't need --> | |
</span> | |
</td> |
const fs = require('fs') | |
const cheerio = require('cheerio') | |
console.log('Reading File fooTable.html...') | |
const parsedHTML = fs.readFileSync('./footable.html', 'utf8') | |
const $ = cheerio.load(parsedHTML, { | |
normalizeWhitespace: true | |
}) |
const db = require('../models') | |
db.sequelize.sync().then(function () { | |
// Require our JSON | |
const cardJson = require('../.data/cards.json').cards | |
// For Each card, let's associate it! | |
cardJson.forEach(async card => { | |
// get the Model for the current card | |
const cardModel = await db.Card.findOne({ |
let transaction | |
try { | |
// Unmanaged Transaction | |
transaction = await sequelize.transaction() | |
// make sure to use the transaction in options | |
await Team.create({...},{transaction}) | |
// always call commit at the end | |
await transaction.commit() |
let transaction | |
let teamToUpdate | |
try { | |
transaction = await sequelize.transaction() // Managed Transaction | |
// update the team | |
teamToUpdate = await Team.findOne({ where: {...}, transaction }) | |
/* POTENTIAL ERROR - .update of null */ | |
await teamToUpdate.update({...}, {transaction}) | |
catch (err) { | |
// never forget to rollback | |
await transaction.rollback() | |
if (err instanceof TypeError) { | |
// we know now that we couldn't find a team | |
return res.status(404).send('useful message regarding team not found') | |
} | |
else if (err.message === 'tag not found') { |
<div class="svg-wrapper"> | |
<svg | |
class="svg-paper" | |
id="paper" | |
preserveAspectRatio="xMidYMid meet" | |
viewbox="0 0 400 400" | |
width="100%" | |
xmlns="http://www.w3.org/2000/svg" | |
xmlns:svg="http://www.w3.org/2000/svg"> | |
<g class="svg-paper__group"> |
function draw () { | |
let WIDTH = visualizer.width | |
let HEIGHT = visualizer.height | |
// loop this | |
window.requestAnimationFrame(draw) | |
// get the current Data (gets placed into array arg) | |
player.getAnalyzerTimeBytes(1, f1visualData) | |
player.getAnalyzerTimeBytes(2, f2visualData) |
<div class="navigation"> | |
<input class="navigation__cbox" id="DrawerToggle" type="checkbox"/> | |
<label class="navigation__hamburger-box" for="DrawerToggle"> | |
</label> | |
</div> |