New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rdf-sparql-builder

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdf-sparql-builder

SPARQL query builder

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
264
decreased by-32.13%
Maintainers
0
Weekly downloads
 
Created
Source

rdf-sparql-builder

build status npm version

rdf-sparql-builder helps building SPARQL queries in JavaScript code. Instead of error-prone string concatenations, method chaining allows writing queries without switching the programming language. The RDF/JS data model is used for terms like named nodes and variables.

Usage

The package exports an object with all the required functions. It can be imported in your code like this:

import * as sparql from 'rdf-sparql-builder'

Example

The following example shows how to build a simple query. The examples folder contains more examples showing all kinds of features supported by the package.

import rdf from '@rdfjs/data-model'
import namespace from '@rdfjs/namespace'
import * as sparql from 'rdf-sparql-builder'

const ns = {
  ex: namespace('http://example.org/'),
  rdf: namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
}

const observation = rdf.variable('observation')
const date = rdf.variable('date')
const temperature = rdf.variable('temperature')

const query = sparql.select([date, temperature])
  .where([
    [observation, ns.rdf.type, ns.ex.Observation],
    [observation, ns.ex.date, date],
    [observation, ns.ex.temperature, temperature]
  ])

console.log(query.toString())

FAQs

Package last updated on 29 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc