Skip to content

Instantly share code, notes, and snippets.

View elvis-onobo's full-sized avatar
:octocat:
Value Driven

Elvis Onobo elvis-onobo

:octocat:
Value Driven
View GitHub Profile
const User = use('App/Models/user')
const Article = use('App/Models/Article')
const Database = use('Database')
async createArticleWithUser({ request, response, session }) {
const trx = await Database.beginTransaction()
try{
const { topic } = request.post()
@elvis-onobo
elvis-onobo / DBTranxStory.js
Created December 10, 2020 11:09
DB Operations Mistake
if (CustomerFundsDeducted()) {
PostFundsToStore()
} else {
// throw an error
}
@elvis-onobo
elvis-onobo / RegisterController.js
Created November 19, 2020 10:08
Database Transaction with Express Js and Objection.js
"use strict";
const jwt = require("jsonwebtoken");
const bcrypt = require("bcrypt");
const randomstring = require("randomstring");
const nodemailer = require("nodemailer");
const env = require("dotenv").config();
const mailgun = require("mailgun-js");
const credentials = {
apiKey: process.env.AFRICASTALKING_API_KEY, // use your sandbox app API key for development in the test environment