当前位置: 首页 > 知识库问答 >
问题:

为什么我在Neo4j浏览器中得到一个Neo4j Cypher参数语法错误

那利
2023-03-14

我得到了

“需要名为ParamEmail的参数”

CREATE (user:Owner {
   email:{paramEmail},
   password:{paramPassword},
   name:{paramName},
   category:{paramCategory}})
RETURN properties(user),
{
   paramEmail: "555@ali.com",
   paramPassword: "5555555",
   paramName: "Tony",
   paramCategory: "Category"
}
params: {parama:a,paramb:b,paramc:c}
neo4jSession
        .run ("MATCH (user {email : {paramEmail}}) RETURN count(user)=1 as user_exists",{ paramEmail: newUser.email})

        .then (function(result) {
            console.log("Neo4j Session started");
            if ( result.records[0].get('user_exists') !== true ) 
              {
            neo4jSession
              .run("CREATE (user:Owner {email:{paramEmail}, password:{paramPassword}, name:{paramName}, category:{paramCategory}}) RETURN properties (user)",
                {params: {
                    paramEmail: newUser.email,
                    paramPassword: newUser.password,
                    paramName: newUser.name,
                    paramCategory: newUser.category
                    }})
 //            .run (CREATE (user:newUser.category {email: {newUser.email}, password: {newUser.password}, 
  //                name: {newUser.name}, mobilenumber: {newUser.mobilenumber}) ASSERT newUser.email is UNIQUE RETURN properties (user));

                console.log( result.records[0].get("email") + " " + result.records[0].get("name") );
                neo4jSession.close();
              }
            else   // (found)
             {
               //   email address already exist
                console.log("email address already exist");
                neo4jSession.close();
             }  //end o f else

             //catch any system errors
        .then (function(error)
            {
            neo4jSession.close();   
            console.log(error);
            });
          }) // end of .then
var neo4j = require('neo4j-driver').v1;
var neo4jdb = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic("neo4j", "neo4j"),
     {
          trust: "TRUST_ON_FIRST_USE",
          encrypted:true
     });

var neo4jSession =neo4jdb.session();
 console.log("Neo4j Session about to start")
//start neo4j session
     neo4jSession
        .run ("MATCH (user {email : {paramEmail}}) RETURN count(user)=1 as user_exists",{ paramEmail: newUser.email})
        .then (function(result) {
            console.log("Neo4j Session started")
            if ( result.records[0].get('user_exists') !== true ) 
              {
            neo4jSession
              .run("CREATE (user:Owner {email:{paramEmail}, password:{paramPassword}, name:{paramName},mobilenumber:{parammobileNumber}, category:{paramCategory}}) RETURN user",
                {params: {
                    paramEmail: newUser.email,
                    paramPassword: newUser.password,
                    paramName: newUser.name,
                    parammobileNumber: newUser.mobilenumber,
                    paramCategory: newUser.category
                    }})
              .then (function(result)
                      {
                         console.log(user.name);
                         neo4jSession.close();  

                     })
              .then (function(error)
                      {
                         neo4jSession.close();  
                         console.log(error);
                     })

 //            .run (CREATE (user:newUser.category {email: {newUser.email}, password: {newUser.password}, 
  //                name: {newUser.name}, mobilenumber: {newUser.mobilenumber}) ASSERT newUser.email is UNIQUE RETURN properties (user));

                console.log( result.records[0].get("email") + " " + result.records[0].get("name") );
                neo4jSession.close();
              }
            else   // (found)
             {
               //   email address already exist
                console.log("email address already exist");
                neo4jSession.close();
             }  //end o f else
            }) // end of .then
             //catch any system errors
        .then (function(error)
            {
            neo4jSession.close();   
            console.log(error);
            });

共有1个答案

景光赫
2023-03-14

除非最近发生了一些我不知道的变化,否则web界面不支持参数(尽管neo4j shell支持这些参数,并且是以编程方式支持的)。

 类似资料: