Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does rueidis support MULTI/EXEC in redisgraph? #43

Closed
ebrahimtorabi opened this issue May 28, 2022 · 3 comments
Closed

Does rueidis support MULTI/EXEC in redisgraph? #43

ebrahimtorabi opened this issue May 28, 2022 · 3 comments

Comments

@ebrahimtorabi
Copy link

Does rueidis support MULTI/EXEC in redisgraph?
if yes please give me a example

@rueian
Copy link
Collaborator

rueian commented May 29, 2022

Hi @ebrahimtorabi,

Yes, It supports it. Here is an example:

package main

import (
	"context"
	"fmt"

	"github.com/rueian/rueidis"
)

func main() {
	c, err := rueidis.NewClient(rueidis.ClientOption{
		InitAddress: []string{"127.0.0.1:6379"},
	})
	if err != nil {
		panic(err)
	}
	defer c.Close()

	ctx := context.Background()

	if err := c.Dedicated(func(client rueidis.DedicatedClient) error {
		prepares := rueidis.Commands{
			client.B().Multi().Build(),
			client.B().Del().Key("movies").Build(),
			client.B().GraphQuery().Graph("movies").Query("CREATE (:Actor {name:'Mark Hamill', actor_id:1}), (:Actor {name:'Harrison Ford', actor_id:2}), (:Actor {name:'Carrie Fisher', actor_id:3})").Build(),
			client.B().GraphQuery().Graph("movies").Query("CREATE (:Movie {title:'Star Wars: Episode V - The Empire Strikes Back', release_year: 1980 , movie_id:1})").Build(),
			client.B().Exec().Build(),
		}
		return client.DoMulti(ctx, prepares...)[len(prepares)-1].Error()
	}); err != nil {
		panic(err)
	}

	resp, err := c.Do(ctx, c.B().GraphQuery().Graph("movies").Query("MATCH (m:Movie) WHERE m.movie_id = 1 RETURN m").Build()).ToArray()
	if err != nil {
		panic(err)
	}
	nodes, err := resp[1].ToArray()
	if err != nil {
		panic(err)
	}
	for _, node := range nodes {
		fmt.Println(node.ToAny())
	}
}

@ebrahimtorabi
Copy link
Author

thanks for your reply

@rueian
Copy link
Collaborator

rueian commented Jun 2, 2022

I am going to close this issue. Feel free to reopen or open another issue if you need further help.

@rueian rueian closed this as completed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants