Я написал код в NodeJS, который создает запросы для базы данных.Я не понимаю, почему в запросе появляется нежелательная обратная косая черта "\". Я попытался удалить обратную косую черту явно с помощью команды .replace (/ \ / g, ''), но безрезультатно.Какой обходной путь для этого?
Код NodeJS
app.controller.js
function createCypherQueries(data,parent,type,parentType){
var macthQuery;
var createQuery;
var relationQuery;
var completeQuery;
var lowerCaseParent;
var lowerCaseParentType;
var lowerCaseData;
var lowerCaseType;
var completeCypherQuery1;
lowerCaseParent = parent!=null?parent:'yo';
lowerCaseParent = lowerCaseParent.replace(/[^a-zA-Z0-9_ ]/g, "").toLowerCase();
lowerCaseData = data.toLowerCase();
lowerCaseData = lowerCaseData.replace(/[^a-zA-Z0-9_ ]/g, "");
lowerCaseType = type!=null?type:'';
lowerCaseType = lowerCaseType.replace(/[^a-zA-Z0-9_ ]/g, "");
// with ' ;
matchQuery = "Match (" + lowerCaseParent + ":" + lowerCaseParent +") where "+ lowerCaseParent +".name ='"+ parent +"' ";
createQuery = "Create ("+ lowerCaseData +":"+ lowerCaseData +"{name:'"+ data +"'})";
relationQuery = "("+ lowerCaseParent +")-[:"+ type +"]->("+lowerCaseData +")";
if(parent == null){
if(type=="Organization"){
createQuery = "Create (" + organization.toLowerCase() + ":" + organization.toLowerCase() +"{name:'"+organization+"'})";
completeQuery = createQuery;
completeCypherQuery1 = completeQuery.replace(/\\/g, '');
orgTree = completeCypherQuery1;
}
else{
parentType= "System";
lowerCaseParent = system!=null?system.toLowerCase():'noData';
lowerCaseData = data.toLowerCase();
lowerCaseType = type!=null?type.toLowerCase():'';
matchQuery = "Match ("+ lowerCaseParent +":"+ lowerCaseParent +") where "+ lowerCaseParent +".name ='"+ system +"'" ;
createQuery = "Create ("+ lowerCaseData +":"+ lowerCaseData+"{name:'" + data+ "'})";
relationQuery = "("+ lowerCaseParent +")-[:"+type+"]->(" + lowerCaseData + ")";
completeQuery = matchQuery + createQuery +"," + relationQuery;
completeCypherQuery1 = completeQuery.replace(/\\/g, '');
allQueries.push(completeCypherQuery1);
}
}
else{
completeQuery = matchQuery+createQuery+","+relationQuery;
completeCypherQuery1 = completeQuery.replace(/\\/g, '');
}
allQueries.push(completeCypherQuery1);
console.log( " zzzzz",allQueries);
}
// CREATES CYPHER QUERIES FROM WSDL FILE ENDS HERE *******************************************
}
});
Вывод -
zzzzz [ 'Create (naya:naya{name:\'Naya\'})',
'Match (naya:naya) where naya.name =\'Naya\' Create (it:it{name:\'IT\'}),(naya)-[:Department]->(it)',
'Match (it:it) where it.name =\'IT\' Create (test:test{name:\'Test\'}),(it)-[:System]->(test)',
'Match (test:test) where test.name =\'Test\' Create (ngoconnectionserviceimpl:ngoconnectionserviceimpl{name:\'NGOConnectionServiceImpl\'}),(test)-[:Function]->(ngoconnectionserviceimpl)',
'Match (ngoconnectionserviceimpl:ngoconnectionserviceimpl) where ngoconnectionserviceimpl.name =\'NGOConnectionServiceImpl\' Create (ngoconnectionserviceimplhttpsoap11endpoint:ngoconnectionserviceimplhttpsoap11endpoint{name:\'NGOConnectionServiceImplHttpSoap11Endpoint\'}),(ngoconnectionserviceimpl)-[:Port]->(ngoconnectionserviceimplhttpsoap11endpoint)',
'Match (disconnectcab:disconnectcab) where disconnectcab.name =\'disconnectCab\' Create (input:input{name:\'input\'}),(disconnectcab)-[:Parameter]