Skip to content

Instantly share code, notes, and snippets.

@acunniffe
Created March 25, 2018 23:55
Show Gist options
  • Save acunniffe/4dd226f885a9881ac81860097e1134dd to your computer and use it in GitHub Desktop.
Save acunniffe/4dd226f885a9881ac81860097e1134dd to your computer and use it in GitHub Desktop.
Optic Transformation Example
//input
const toDo = mongoose.model('todo', new mongoose.Schema({
'message': 'string',
'isDone': 'string'
}))
//output
app.post('/todo', (req, res)=> {
new toDo({
message: req.body.message,
isDone: req.body.isDone
}).save((err, item)=> {
if (!err) {
res.send(200, item)
} else {
res.send(400, err)
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment