Created
March 13, 2020 17:30
-
-
Save adam-cowley/a5995e72438095b06dec03eddfbd47c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ status: 'success', message: 'Book updated' } | |
{ | |
ISBN: 1, | |
publication: '2020-03-13', | |
createdAt: '2020-03-13T17:30:20.191000000Z' | |
} |
This file contains hidden or 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
// 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