Jonahss / ioredisgraph

Node.js client for RedisGraph, by wrapping ioredis module
ISC License
24 stars 8 forks source link

Best way to do transactions in ioredisgraph #8

Closed renewooller closed 4 years ago

renewooller commented 5 years ago

What's the best way to do transactions currently in ioredisgraph? Is there any plan to add support for MULTI EXEC? Cheers

Jonahss commented 5 years ago

Oh interesting. I'll have to look into it, I'm not super familiar with the subject. A quick look shows that RedisGraph supports MULTI EXEC. And ioredis supports it. There's a chance this module already supports it if you call it the right way, I'd have to experiment.

I'll give it a try this weekend, if you're willing to wait. Or if you want to take a look at the messy details you can give it a shot and submit a PR.

renewooller commented 4 years ago

FYI I just saw this "Because RedisGraph uses Redis Module API multi-threading model we can't have any RedisGraph command within a MULTI-EXEC block." https://github.com/RedisGraph/redisgraph.js/issues/3

Jonahss commented 4 years ago

Oh, but that's a super early issue. There's a later one where they implemented it.

https://github.com/RedisGraph/RedisGraph/pull/352

bionicles commented 4 years ago

@Jonahss love this repo. I want to make a graphql-ioredisgraph docker container with google signin, it's mostly done, what do you think are the minimum covering set (heh) of CRUDL ops for nodes and relations, traversals ?

My thought is to just make a graphql thing for abstract nodes and relationships instead of one per type.

Then we could just put different types as strings, and focus on fine grained access control with Ramda, make a type:field:rule lookup table, get the rules for each field, and check if the user can perform the operation on the given object

Jonahss commented 4 years ago

@bionicles Thanks :)

I'm not too familiar with graphql yet, but once you map each graphql concept to a matching redisgraph concept, it does all the rest for you, right?

Good idea to add google auth and using that to manage your permissions model.

How do you intend to define the schema? Or your saying everything is just node or relationship and the permissioning is all that makes a distinction between them? In that case, how will the permission schema be defined?

Jonahss commented 4 years ago

@renewooller I've just published a new version. I added support for ioredis' pipeline and transaction concepts. transaction uses the Redis MULTI and EXEC commands.

Here's some sample code:

let graph = new RedisGraph('transactions')
let results = await graph.multi()
    .query(`CREATE (:person {name: 'Chuck'})-[:friendsWith]->(:person {name: 'Austin'})`)
    .query(`MATCH (p:person {name: 'Chuck'}) RETURN p`)
    .query(`MATCH (p:person {name: 'Austin'}) RETURN p`)
    .exec()

For more information, see: https://github.com/luin/ioredis#transaction

Thanks for pointing out this missing feature :)

renewooller commented 4 years ago

Thanks Jonahss!