Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andrewhl
Created July 9, 2017 11:14
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 andrewhl/42483fdb4b877e9334caff30b67f48b3 to your computer and use it in GitHub Desktop.
Save andrewhl/42483fdb4b877e9334caff30b67f48b3 to your computer and use it in GitHub Desktop.
// Iterate through request files array and write each file to Neo4j
images.forEach(image => {
session.writeTransaction(tx => {
tx.run(`MATCH (n:Article {uuid: $uuid})-[:HAS]->(f:File)
MERGE (n)-[:HAS]->(i:File {
name: $name,
caption: $caption
}) WITH i,n SET i.uuid = $fileUuid,
i.url = $url,
i.updated_at = $updatedAt,
i.created_at = $createdAt RETURN n`,
{
uuid: req.params.uuid,
fileUuid: uuidV4(),
url: image.url,
name: image.name,
caption: image.caption,
createdAt: moment().format('YYYY-MM-DD'),
updatedAt: moment().format('YYYY-MM-DD'),
})
}).then(result => {
console.log('File saved.')
}).catch(error => {
console.log(error);
driver.close();
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment