本文整理匯總了Golang中github.com/Financial-Times/neo-utils-go/neoutils.CypherRunner.CypherBatch方法的典型用法代碼示例。如果您正苦於以下問題:Golang CypherRunner.CypherBatch方法的具體用法?Golang CypherRunner.CypherBatch怎麽用?Golang CypherRunner.CypherBatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Financial-Times/neo-utils-go/neoutils.CypherRunner
的用法示例。
在下文中一共展示了CypherRunner.CypherBatch方法的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
}
示例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
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}