Esempio n. 1
0
func transaction(db *neoism.Database) {
	qs := []*neoism.CypherQuery{
		&neoism.CypherQuery{
			Statement: `CREATE (n {name: "Scottie", shirt: "red"}) RETURN n`,
		},
		&neoism.CypherQuery{
			Statement: `START n=node(*), m=node(*)
				WHERE m.name = {name} AND n.shirt IN {colors}
				CREATE (n)-[r:outranks]->(m)
				RETURN n.name, type(r), m.name`,
			Parameters: neoism.Props{"name": "Scottie", "colors": []string{"yellow", "blue"}},
			Result: &[]struct {
				N   string `json:"n.name"` // `json` tag matches column name in query
				Rel string `json:"type(r)"`
				M   string `json:"m.name"`
			}{},
		},
	}
	tx, _ := db.Begin(qs)
	fmt.Println(qs[1].Result) // &[{Kirk outranks Scottie} {Spock outranks Scottie} {McCoy o...
	tx.Commit()
}