Closed KunalSaini closed 7 years ago
levelgraph-jsonld stores the fully qualified identifiers, so that you can use various prefixes for data coming in and out of the database.
If you want to write queries using your prefixes, you can simply define a small prefix mapping function like so:
// `context` is assumed to be your global @context's value--customize to your liking ^_^
function unprefix(id) {
var bits = id.split(':');
var base = context[bits[0]];
return base + bits[1];
}
Which would allow you to do the following:
db.search([{
subject: db.v('x'),
predicate: unprefix('rel:isRelatedTo'),
object: db.v('y'),
}]
However, this is a minimal effort sort of mapping and may not (i.e. likely won't) scale to more complex contexts--in which case using something like jsonld.js might be best.
This is a common problem/need, but it's not one levelgraph-jsonld is likely to solve directly.
Thoughts?
thanks, I did wrote simple prifixer/unprefix function as you suggested for now. my scenario is fairly simple so i can live with this mapper.
Hi, I am trying to search on a jsonld representation using below code
This works , however i want to not specify
predicate
as full namespace instead i want to leverage the context information when searching. something likefollowing is the context object as specified in my
/db/dbfile.jsonld
file