Gun: Doing a matching by two tags

Created on 10 Apr 2017  路  4Comments  路  Source: amark/gun

Seems GUN can only matching data by one path, I'm wondering how I can matching data like this:

gun.get('tags').path(tag1).intersect().get('tags').path(tag2).map().val((notes, tag) => {
      this.setState(prevState => ({
        results: [...prevState.results, notes]
      }))
    }))

In neo4j's cypher this is like:

Match (tag1)->(result)<-(tag2) Return result

Can I do this graph matching in GUN? If not, will this be a future feature?

Most helpful comment

No promises because my current schedule is 'uncertain' but i'll do my best to update 'guntagger' ASAP ( like ...give me a week )

All 4 comments

@linonetwo yes, @Stefdv built a tagging extension/library for just this. However, I think he still needs to publish the 0.7 updates, so let me check in with him. (We've been chatting about possibly including it in the main gun repo)

Just to clarify, you want all the items in the UNION of 2 tags, right?

@amark Sorry for being ambiguous, but I actually want intersection, since I'm building an offline cheat sheet for my exam, I need to find _the note that has two tags at the same time_.

I think I can do this with RxJS, but I don't know when the stream of .map().val(() => {}) is _finished_, so I don't know when to start doing intersection.

Seems .map().val(() => {}) can't inform me that I have to go through the whole map because gun needs to handle some realtime update? ( some peer will add some data into that map at any time )

Thanks!

No promises because my current schedule is 'uncertain' but i'll do my best to update 'guntagger' ASAP ( like ...give me a week )

@linonetwo this is now available in @Stefdv 's npm install gun-tag module using the gun.intersect() method on his tagging chain extensions. Repo here: https://github.com/Stefdv/gun-tag . (I need to get this module published to the README soon!)

Closing! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

corporatepiyush picture corporatepiyush  路  6Comments

Xsmael picture Xsmael  路  3Comments

Sarajin picture Sarajin  路  6Comments

ivkan picture ivkan  路  6Comments

finwo picture finwo  路  5Comments