Giter Club home page Giter Club logo

sparql-builder's Introduction

sparql-builder

SPARQL query builder written in TypeScript. Can be used from both TypeScript and JavaScript, although type-safety is lost in JavaScript.

It exposes the following classes:

  • QueryBuilder - builder base class
    • SelectBuilder - SELECT query builder
    • DescribeBuilder - DESCRIBE query builder

Build

The build-dist.sh script does the following:

  • compiles the TypeScript code using tsc
  • runs unit tests using npm test
  • packages the library with webpack
    • for use in the browser (window target, output in dist/window)
    • for use with Node.js (commonjs2 target, output in dist/node)

Usage

The builder is published as sparql-builder package on npm. Import it into your package.json:

    "dependencies": {
        "sparql-builder": "^1.0.6"
    }

Example:

Code in test.ts:

import { SelectBuilder } from 'sparql-builder';

let query = "SELECT ?s { ?s ?p ?o }";

let builder = SelectBuilder.fromString(query).
    limit(42).
    offset(66).
    orderBy(SelectBuilder.ordering(SelectBuilder.var("s"), true)).
    orderBy(SelectBuilder.ordering(SelectBuilder.var("p")));

console.log(builder.toString());

Output of tsc && node test.js:

SELECT ?s WHERE { ?s ?p ?o. }
ORDER BY DESC (?s) (?p)
OFFSET 66
LIMIT 42

sparql-builder's People

Contributors

namedgraph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sparql-builder's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.