Skip to content

Instantly share code, notes, and snippets.

/1imageController.js Secret
Created May 20, 2017

Embed
What would you like to do?
imageController.saveNewImage = (req,res) =>{
console.log(req.body);
const image = {
image_title: req.body.title,
image_description: req.body.description,
image_path: req.body.path,
image_created_at: new Date()
};
knex('images')
.insert(image)
.then ( newImage =>{
res.json(newImage);
})
};
{
"command": "INSERT",
"rowCount": 1,
"oid": 0,
"rows": [],
"fields": [],
"_parsers": [],
"RowCtor": null,
"rowAsArray": false
}
{
"id":12,
"image_title":"test image",
"image_description":"test description",
"image_path":"test image path",
...
}
{
"title":"test image",
"description":"Test description",
"path":"test image path"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.