本文整理汇总了Golang中github.com/Financial-Times/neo-utils-go/neoutils.CypherRunner类的典型用法代码示例。如果您正苦于以下问题:Golang CypherRunner类的具体用法?Golang CypherRunner怎么用?Golang CypherRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CypherRunner类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getNodeRelationshipNames
func getNodeRelationshipNames(cypherRunner neoutils.CypherRunner, uuid string) (relationshipsFromNodeWithUUID relationships, relationshipsToNodeWithUUID relationships, err error) {
// find all the -> relationships
relationshipsFromNodeWithUUID = relationships{}
readRelationshipsFromNodeWithUUIDQuery := &neoism.CypherQuery{
Statement: `match (a:Thing{uuid:{uuid}})-[r]->(b)
return distinct type(r) as relationship`,
Parameters: map[string]interface{}{
"uuid": uuid,
},
Result: &relationshipsFromNodeWithUUID,
}
// find all the <- relationships
relationshipsToNodeWithUUID = relationships{}
readRelationshipsToNodeWithUUIDQuery := &neoism.CypherQuery{
Statement: `match (a:Thing{uuid:{uuid}})<-[r]-(b)
return distinct type(r) as relationship`,
Parameters: map[string]interface{}{
"uuid": uuid,
},
Result: &relationshipsToNodeWithUUID,
}
readQueries := []*neoism.CypherQuery{readRelationshipsFromNodeWithUUIDQuery, readRelationshipsToNodeWithUUIDQuery}
err = cypherRunner.CypherBatch(readQueries)
if err != nil {
return nil, nil, err
}
return relationshipsFromNodeWithUUID, relationshipsToNodeWithUUID, nil
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:33,代码来源:relationship_transfer.go
示例2: readRelationshipDetails
// return relationship details in both directions
func readRelationshipDetails(cypherRunner neoutils.CypherRunner, contentType string, orgUUID string) ([]property, []property, error) {
transferredLRProperty := []property{}
readRelationshipsQueryLR := &neoism.CypherQuery{
Statement: fmt.Sprintf(`match (co:%s)-[r]->(c:Thing{uuid:{uuid}})
return r.platformVersion, type(r) as name`, contentType),
Parameters: map[string]interface{}{
"uuid": orgUUID,
},
Result: &transferredLRProperty,
}
transferredRLProperty := []property{}
readRelationshipsQueryRL := &neoism.CypherQuery{
Statement: fmt.Sprintf(`match (co:%s)<-[r]-(c:Thing{uuid:{uuid}})
return r.platformVersion, type(r) as name`, contentType),
Parameters: map[string]interface{}{
"uuid": orgUUID,
},
Result: &transferredRLProperty,
}
err := cypherRunner.CypherBatch([]*neoism.CypherQuery{readRelationshipsQueryLR, readRelationshipsQueryRL})
return transferredLRProperty, transferredRLProperty, err
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:27,代码来源:service_concording_scenarios_test.go
示例3: cleanDB
func cleanDB(db neoutils.CypherRunner, t *testing.T, assert *assert.Assertions, uuidsToClean []string) {
qs := []*neoism.CypherQuery{}
for _, uuid := range uuidsToClean {
qs = append(qs, &neoism.CypherQuery{Statement: fmt.Sprintf("MATCH (org:Thing {uuid: '%v'})<-[:IDENTIFIES*0..]-(i:Identifier) DETACH DELETE org, i", uuid)})
qs = append(qs, &neoism.CypherQuery{Statement: fmt.Sprintf("MATCH (org:Thing {uuid: '%v'}) DETACH DELETE org", uuid)})
}
err := db.CypherBatch(qs)
assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:11,代码来源:test_utils.go
示例4: cleanDB
func cleanDB(db neoutils.CypherRunner, t *testing.T, assert *assert.Assertions) {
qs := []*neoism.CypherQuery{
{
Statement: fmt.Sprintf("MATCH (mc:Thing {uuid: '%v'}) DETACH DELETE mc", minimalContentUuid),
},
{
Statement: fmt.Sprintf("MATCH (fc:Thing {uuid: '%v'}) DETACH DELETE fc", fullContentUuid),
},
}
err := db.CypherBatch(qs)
assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:content-rw-neo4j,代码行数:13,代码来源:content_service_test.go
示例5: cleanRelationshipDB
func cleanRelationshipDB(db neoutils.CypherRunner, t *testing.T, assert *assert.Assertions, uuidsToClean []string) {
cleanDB(db, t, assert, uuidsToClean)
qs := []*neoism.CypherQuery{
{
Statement: fmt.Sprintf("MATCH (c:Content {uuid: '%v'})-[rel]-(o) DELETE c, rel ", relationShipTransferContentUUID),
},
{
Statement: fmt.Sprintf("MATCH (c:Content {uuid: '%v'}) DELETE c ", relationShipTransferContentUUID),
},
}
err := db.CypherBatch(qs)
assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:15,代码来源:relationship_transfer_test.go
示例6: deleteAllViaService
func deleteAllViaService(db neoutils.CypherRunner, assert *assert.Assertions, annotationsRW annotations.Service) {
_, err := annotationsRW.Delete(contentUUID)
assert.Nil(err)
qs := []*neoism.CypherQuery{
{
Statement: fmt.Sprintf("MATCH (c:Thing {uuid: '%v'})-[rel]-(o) DELETE c, rel ", contentUUID),
},
{
Statement: fmt.Sprintf("MATCH (c:Thing {uuid: '%v'}) DELETE c ", contentUUID),
},
}
err = db.CypherBatch(qs)
assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:16,代码来源:service_concording_scenarios_test.go
示例7: checkDbClean
func checkDbClean(db neoutils.CypherRunner, t *testing.T, uuidsToClean []string) {
assert := assert.New(t)
result := []struct {
UUID string `json:"org.uuid"`
}{}
checkGraph := neoism.CypherQuery{
Statement: `
MATCH (org:Thing) WHERE org.uuid in {uuids} RETURN org.uuid
`,
Parameters: neoism.Props{
"uuids": uuidsToClean,
},
Result: &result,
}
err := db.CypherBatch([]*neoism.CypherQuery{&checkGraph})
assert.NoError(err)
assert.Empty(result)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:20,代码来源:test_utils.go
示例8: writeClassifedByRelationship
func writeClassifedByRelationship(db neoutils.CypherRunner, contentId string, conceptId string, lifecycle string, t *testing.T, assert *assert.Assertions) {
var annotateQuery string
var qs []*neoism.CypherQuery
if lifecycle == "" {
annotateQuery = `
MERGE (content:Thing{uuid:{contentId}})
MERGE (upp:Identifier:UPPIdentifier{value:{conceptId}})
MERGE (upp)-[:IDENTIFIES]->(concept:Thing) ON CREATE SET concept.uuid = {conceptId}
MERGE (content)-[pred:IS_CLASSIFIED_BY {platformVersion:'v1'}]->(concept)
`
qs = []*neoism.CypherQuery{
{
Statement: annotateQuery,
Parameters: neoism.Props{"contentId": contentId, "conceptId": conceptId},
},
}
} else {
annotateQuery = `
MERGE (content:Thing{uuid:{contentId}})
MERGE (upp:Identifier:UPPIdentifier{value:{conceptId}})
MERGE (upp)-[:IDENTIFIES]->(concept:Thing) ON CREATE SET concept.uuid = {conceptId}
MERGE (content)-[pred:IS_CLASSIFIED_BY {platformVersion:'v1', lifecycle: {lifecycle}}]->(concept)
`
qs = []*neoism.CypherQuery{
{
Statement: annotateQuery,
Parameters: neoism.Props{"contentId": contentId, "conceptId": conceptId, "lifecycle": lifecycle},
},
}
}
err := db.CypherBatch(qs)
assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:annotations-rw-neo4j,代码行数:37,代码来源:cypher_test.go
注:本文中的github.com/Financial-Times/neo-utils-go/neoutils.CypherRunner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论