當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CypherRunner.CypherBatch方法代碼示例

本文整理匯總了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
}
開發者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.CypherBatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。