Skip to content

Instantly share code, notes, and snippets.

Created May 20, 2017 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6c4f1e1e8fd42fd3114ac6027d1e3b0a to your computer and use it in GitHub Desktop.
Save anonymous/6c4f1e1e8fd42fd3114ac6027d1e3b0a to your computer and use it in GitHub Desktop.
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