我有以下函数将一行数据插入基于行的条目(excell或csv条目)到我的neo4j中:
self.insertFromExcellRow=function(row){
// _neo4j a neo4j connection from neo4j-driver
const session = _neo4j.session();
//The replacement of the values where it will get stored in neo4j
const values={
'dataid':row.dataId,
'dataAsset':row.dataAsset,
'dataSubject':row.dataSubject,
'purpoce':row.purpoce,
'source':row.source,
'pIIclasification':row.pIIclasification,
'securityClassification':row.securityClassification,
'categoryInfo':row.categoryInfo,
'appName':row.collectedBy,
'securityControl':row.securityControl,
'usedBy':row.usedBy,
'whoCanAccess':row.access,
'securityControl':row.securityControl,
'dataTransferMechanism':row.dataTranserMechanism,
'serviceName':row.collectedBy
}
let query=`MERGE (DATA_ASSET:DATA_ASSET {id:{dataid} ,name:{dataAsset}, subject:{dataSubject}, classification:{securityClassification})
MERGE (SERVER_OR_SERVICE:SERVER_OR_SERVICE { name: {serviceName} })
MERGE (APPLICATION:APPLICATION { name:{appName} })
MERGE (DATA_CONSUMER:DATA_CONSUMER {usedBy: {usedBy}, accessOrgPositions: {whoCanAccess}})
MERGE (SERVER_OR_SERVICE)<-[:FROM]-(DATA_CONSUMER)-[:ACCESSING]->(DATA_ASSET)
MERGE (DATA_ASSET)-[:COLLECTED_BY]->(APPLICATION)
`;
if(row.processingType.toLowerCase()==='transmission') {
query+=`MERGE (DATA_ASSET)-[:GETS]->(TRANSMITTED:TRANSMITTED { id:{dataid},purpoce:{purpoce},source:{source},pIIclasification:{pIIclasification},categoryInfo:{categoryInfo} })<-[:FROM]-(APPLICATION)
MERGE (DATA_ASSET)-[:GETS]->(TRANSMITTED)-[:INTO { transferMechanism:{dataTransferMechanism}, securityControl:{securityControl}}]->(SERVER_OR_SERVICE)`;
} else if(row.processingType.toLowerCase()==='storage') {
query+=`MERGE (DATA_ASSET)-[:GETS]->(STORED:STORED { id:{dataid},purpoce:{purpoce},source:{source},pIIclasification:{pIIclasification},categoryInfo:{categoryInfo} })<-[:FROM]-(APPLICATION)
MERGE (DATA_ASSET)-[:GETS]->(STORED)-[:INTO { transferMechanism:{dataTransferMechanism}, securityControl:{securityControl}}]->(SERVER_OR_SERVICE)`;
}
session.run(query,values).then((data)=>{
console.log('Success');
self.fetchDataAsTable();
}).catch((error)=>{
_emmiter.emit('insert_row_error',error);
console.error(error);
});
}
但由于某种原因,我收到错误:
{ Neo4jError: Invalid input ')': expected whitespace, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, ',' or '}' (line 1, column 124 (offset: 123))
"MERGE (DATA_ASSET:DATA_ASSET {id:{dataid} ,name:{dataAsset}, subject:{dataSubject}, classification:{securityClassification})"
^
at captureStacktrace (/opt/map/node_modules/neo4j-driver/lib/v1/result.js:200:15)
at new Result (/opt/map/node_modules/neo4j-driver/lib/v1/result.js:73:19)
at Session._run (/opt/map/node_modules/neo4j-driver/lib/v1/session.js:122:14)
at Session.run (/opt/map/node_modules/neo4j-driver/lib/v1/session.js:101:19)
at self.insertFromExcellRow (/opt/map/src/services/graph.js:67:15)
at /opt/map/src/services/excell.js:118:7
at process._tickCallback (internal/process/next_tick.js:150:11)
code: 'Neo.ClientError.Statement.SyntaxError',
name: 'Neo4jError' }
你们的伙伴们能弄明白为什么吗?
答案 0 :(得分:0)
看起来您需要插入结束}
MERGE(DATA_ASSET:DATA_ASSET {id:{dataid},name:{dataAsset},subject:{dataSubject},分类:{securityClassification} here )
关闭&#39; DATA_ASSET:DATA_ASSET&#39; {..}
如果错误消息说的话会更好:&#34;你需要一个结束的大括号&#34;而不是向你扔字典 - 最后一个选项是你需要的,大声笑..
至少,它有一个很好的&#39; ^&#39;字符,显示错误的位置。