对使用新主义 golang 的集合有困难的 CYPHER 查询吗?
Have difficult CYPHER query about collection using neoism golang?
我建立了一个社交网络,当评论中包含提及(如 Facebook)时,我将评论 json 发送到网络服务:
{
"owner": 5, // id of user write comment
"message": "text",
"mentions":[
{
"id": 1, // user id
"name": "mention", // name is shown
"offset": 0, // position of start of mention text
"length": 10 // length of mention text
},
{
"id": 2, // user id
"name": "mention", // name is shown
"offset": 0, // position of start of mention text
"length": 10 // length of mention text
}
],
}
数据模型:
(用户)-[写入]->(评论{消息})-[提及{名称、偏移量、长度}]->(用户)
在源代码中,我使用下面的代码来return res with comment
cq := neoism.CypherQuery{
Statement: stmt,
Parameters: params,
Result: &res,
}
我的问题是我不知道如何为此编写查询。对我来说太难了。
这里是如何在不首先分解 json 的情况下制作 Cypher。
WITH {json} AS map
MATCH (u:User)
WHERE id(u)=map.owner
CREATE (u)-[:WRITE]->(c:Comment{message:map.message})
FOREACH (mention IN map.mentions |
MATCH (u2:User) WHERE id(u2) = mention.id
CREATE (c)-[:MENTION{name:mention.name, length:mention.length, offset:mention.offset}]->(u2))
RETURN id(c) AS id
我建立了一个社交网络,当评论中包含提及(如 Facebook)时,我将评论 json 发送到网络服务:
{
"owner": 5, // id of user write comment
"message": "text",
"mentions":[
{
"id": 1, // user id
"name": "mention", // name is shown
"offset": 0, // position of start of mention text
"length": 10 // length of mention text
},
{
"id": 2, // user id
"name": "mention", // name is shown
"offset": 0, // position of start of mention text
"length": 10 // length of mention text
}
],
}
数据模型: (用户)-[写入]->(评论{消息})-[提及{名称、偏移量、长度}]->(用户)
在源代码中,我使用下面的代码来return res with comment
cq := neoism.CypherQuery{
Statement: stmt,
Parameters: params,
Result: &res,
}
我的问题是我不知道如何为此编写查询。对我来说太难了。
这里是如何在不首先分解 json 的情况下制作 Cypher。
WITH {json} AS map
MATCH (u:User)
WHERE id(u)=map.owner
CREATE (u)-[:WRITE]->(c:Comment{message:map.message})
FOREACH (mention IN map.mentions |
MATCH (u2:User) WHERE id(u2) = mention.id
CREATE (c)-[:MENTION{name:mention.name, length:mention.length, offset:mention.offset}]->(u2))
RETURN id(c) AS id