Last active
March 30, 2017 05:28
-
-
Save mrowa44/0f048f5b4802f066a81d9df07655ce06 to your computer and use it in GitHub Desktop.
run with `node --inspect console.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
'use strict'; | |
const repl = require('repl'); | |
// const request = require('supertest'); | |
// const app = require('./app'); | |
const models = require('./models'); | |
const context = repl.start('node> ').context; | |
context.models = models; | |
// context.server = request(app); | |
// server.post('/api/users') | |
// .send({ username: 'Justyna', password: 'pass' }) | |
// .end((err, res) => console.log(res.body)) | |
Object.keys(models).forEach((name) => { context[name] = models[name]; }); | |
// assign promise result to variable | |
// > assign('user', User.find({ where: { username: 'JaneDoe' } })) | |
context.assign = (name, promise) => { | |
promise.then((obj) => { | |
if (obj) { | |
obj.print = () => obj.dataValues; | |
obj.keys = () => Object.keys(obj); | |
obj.log = () => console.log(obj); | |
context[name] = obj; | |
} | |
}); | |
}; | |
console.log(`Available models: ${Object.keys(models).join(', ')}`); | |
debugger; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment