stefdv / gun-tag Goto Github PK
View Code? Open in Web Editor NEWAdd tagging to Gundb
Add tagging to Gundb
I can't tell from the docs, if that's the intended behavior, but I think the gun.tagged() is not behaving as expected when run on a node (not on root). For example, I am trying to do:
this.$gun.get('someitem').put({ title: 'SOME ITEM' })
this.$gun.get('someitem').tag([’tag1, ’tag2’])
//later then…
this.$gun
.get('someitem')
.tagged(r => {
console.log(r)
})
It doesn’t even run. I see the tags property is there on the node, e.g. gun.get('someitem').get('tags')
but I just can’t get the list with .tagged()
I’ve tried with tagged().once( … )
as well.
I would assume the ideal would be to get a callback which:
gun.get('someitem').tagged()
would return all tags on that nodeI am relying on my own getter at the moment, but I am not sure how I can filter out those that have been untagged - as you note in the docs, the tags will show in the tags property even after untagged, but it may not necessarily mean that it's active.
Please see inline comments.
<html>
<body>
<script src="gun_v0.8.3.js"></script>
<script src="gun-tag_v2.0.3.js"></script>
<script>
localStorage.clear();
var gun = Gun();
var a = gun.get('alice').put({name:'Alice'});
var b = gun.get('bob').put({name:'Bob'});
var c = gun.get('carl').put({name:'Carl'});
b.tag('friends/alice');
c.tag(['friends/bob','friends/alice']); //c.tag(['friends/alice','friends/bob']) works fine
console.log('Expected:');
console.log('Bob');
console.log('Carl');
console.log('Actual:');
gun.tagged('friends/alice', function(v) {console.log(v.name)}); //Actual: Bob
</script>
</body>
</html>
To me it seems a bit unclear how to best read all the tags attached to a node. To me it seems the Readme contains only examples on how to get the nodes which have a common tag but not the other way round. Am I missing something?
Currently, I'm getting the tags like this
gun.get('something').get('tags').load(tags => {
for (const tag in tags) {
console.log(tag);
}
});
But this seems not to hold for untagged tags. How do I get all the (not untagged) tags which are attached to 'something'?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.