bank

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 6 Imported by: 0

README

bank

Package bank provides a query bank for sparql queries.

It works by processing data which looks like:

# Comments will be ignored, except those tagging a query

# tag: q0
SELECT * WHERE { ?s ?p ?o }

# tag: q1
SELECT *
WHERE
 {
  ?s ?p ?o
  FILTER(?s = <{{.Subj}}>)
 }

# another comment

# tag: q2
SELECT ?s
WHERE { ?s ?p    ?o }
LIMIT {{.L}}
OFFSET {{.O}}

# tag: myq
SELECT *
WHERE {
    { <{{.Res}}> ?p ?o }
    UNION
    { ?s ?p <{{.Res}}> }
}

These queries can then be called by the user specified 'tag', with template values inserted where necessary (via 'text/template')


Readme created from Go doc with goreadme

Documentation

Overview

Package bank provides a query bank for sparql queries.

It works by processing data which looks like:

# Comments will be ignored, except those tagging a query

# tag: q0
SELECT * WHERE { ?s ?p ?o }

# tag: q1
SELECT *
WHERE
 {
  ?s ?p ?o
  FILTER(?s = <{{.Subj}}>)
 }

# another comment

# tag: q2
SELECT ?s
WHERE { ?s ?p    ?o }
LIMIT {{.L}}
OFFSET {{.O}}

# tag: myq
SELECT *
WHERE {
    { <{{.Res}}> ?p ?o }
    UNION
    { ?s ?p <{{.Res}}> }
}

These queries can then be called by the user specified 'tag', with template values inserted where necessary (via 'text/template')

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bank

type Bank map[string]string

Bank is a map of SPARQL queries.

func Load

func Load(r io.Reader) (b Bank)

Load takes an io.Reader, parses its input and extracts SPARQL queries and stores them in a bank. Any query must be preceded by a comment which tags the query with a name.

func (Bank) Prepare

func (b Bank) Prepare(key string, i ...interface{}) (string, error)

Prepare returns the query string given a key, and optionally a struct with exported fields to be interpolated as variables into the query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL