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

LEX with Content-Addressing in user's graph #1267

Open
fitouch opened this issue Jul 29, 2022 · 10 comments
Open

LEX with Content-Addressing in user's graph #1267

fitouch opened this issue Jul 29, 2022 · 10 comments

Comments

@fitouch
Copy link

fitouch commented Jul 29, 2022

https://gun.eco/docs/SEA.certify#5-there-are-ways-to-get-a-list-of-links-added-by-a-particular-user

// 1. We may use a LEX query to get all links for a particular user gun .user(room.pub) .get('#links') .get({'.': {'*': Bob.pub}}) .map() .once((d,k)=> { bobLinks[k]= JSON.parse(d) })

It works only without gun.user(room.pub). Is it a bug? I really want this part for my project.

@bmatusiak
Copy link
Collaborator

bmatusiak commented Jul 30, 2022

i thought the same but you dont necessarily need Content-Addressing in a user graph. as the content is protected by the hash.

so hash it like normal. and save it like normal.. put/store the hash's "soul" in the user graph that points to the hashed content

you may just want to store the soul to have it map/link to it.

@fitouch
Copy link
Author

fitouch commented Jul 30, 2022

I thought about hash it normal, but sometimes I want to edit or delete the message from my own user graph and save soul in the room (user graph). LEX is not working in user graph without hash, is it?

@fitouch
Copy link
Author

fitouch commented Jul 30, 2022

@fitouch
Copy link
Author

fitouch commented Jul 30, 2022

@bmatusiak I kept testing. LEX does not work in user graph at all. How can we fix it?

@bmatusiak
Copy link
Collaborator

use lex in map, not in get, as per @amark

@fitouch
Copy link
Author

fitouch commented Jul 30, 2022

@bmatusiak https://jsfiddle.net/c04fnro3/24/

The operator "=" does not work in user graph, only public graph. Can you test?

@fitouch
Copy link
Author

fitouch commented Jul 30, 2022

@bmatusiak @amark

Here's my fix for LEX in user graph. It works for me, I tested it in public graph, content-addressing in public graph, user graph, and user graph with cerify.

The only thing is that the operator "=" does not work well with content-addressing (key + hash) in user graph and public graph. I'm sure we can fix that but for now I want LEX to work in user graph. Let me know what you think of the code below.

gun.js lines 25 - 41
var ms = ""; String.match = function(t, o){ var tmp, u; if(t) {if (t.split("/").length > 1) ms = t.split("/").pop();} if('string' !== typeof t){ return false } if('string' == typeof o){ o = {'=': o} } o = o || {}; tmp = (o['='] || o['*'] || o['>'] || o['<']); if(o["="] && (ms === tmp || t === tmp)){ return true } else if(o["*"] && (ms.startsWith(tmp) || t.startsWith(tmp))){ return true } else if(o[">"] && (ms > tmp || t > tmp)){ return true } else if(o["<"] && (ms < tmp || t < tmp)){ return true } if(u !== o['=']){ return false; } tmp = (o['*'] || o['>']); if(t.slice(0, (tmp||'').length) === tmp){ return true } if(u !== o['*']){ return false; } if(u !== o['>'] && u !== o['<']){ return (t >= o['>'] && t <= o['<'])? true : false; } if(u !== o['>'] && t >= o['>']){ return true } if(u !== o['<'] && t <= o['<']){ return true } return false; }

@fitouch
Copy link
Author

fitouch commented Jul 30, 2022

@bmatusiak @amark

I spent more time testing with the current code in gun.js and I found that gun.user(Bob.pub).get('list').map().get({'.': { "=": new Date().toISOString() }}) works. Is that expected?

@fitouch
Copy link
Author

fitouch commented Aug 1, 2022

@bmatusiak @amark @orimay

I have a fix for LEX issue. I ran "npm run test" and all passed. Can one of you give me an access to commit my fix and review it?

@fitouch
Copy link
Author

fitouch commented Aug 2, 2022

@amark #1268 is ready for review!

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