Skip to content

Instantly share code, notes, and snippets.

@adam-cowley
Created March 13, 2020 17:30
Show Gist options
  • Save adam-cowley/a5995e72438095b06dec03eddfbd47c1 to your computer and use it in GitHub Desktop.
Save adam-cowley/a5995e72438095b06dec03eddfbd47c1 to your computer and use it in GitHub Desktop.
{ status: 'success', message: 'Book updated' }
{
ISBN: 1,
publication: '2020-03-13',
createdAt: '2020-03-13T17:30:20.191000000Z'
}
// Define a Neode Instance
const neo4j = require("neode")
// Using configuration from .env file
.fromEnv()
// Including the models in the models/ directory
.with({
Books: {
ISBN: {
type: 'int',
primary: true
},
title: {
type: 'string'
},
author: {
type: 'string'
},
publication: {
type: 'date'
},
createdAt: {
type: 'datetime',
default: () => new Date()
}
}
});
const updateByISBN = (req, res, next) => {
neo4j.create('Books', { 'ISBN': 1 })
.then(book => book.update({ publication: new Date() }))
.then(book => console.log(book.properties()))
.catch(e => console.error(e.details))
res.json({ status: 'success', message: 'Book updated'})
}
updateByISBN({}, {json: console.log})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment