# chirql

> Simple, graph-based query language.

Latest version **1.0.16** (published 2017-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install chirql
pnpm add chirql
yarn add chirql
bun add chirql
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.16 |
| Published | 2017-02-02 |
| First published | 2016-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Eamon Muldowney |
| Maintainers | mingushead |
| Keywords | Weaver, Chirql, graph, query, language |

## Links

- npm: https://www.npmjs.com/package/chirql
- npm.io page: https://npm.io/package/chirql

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.79.0
- [sparql-client](https://npm.io/package/sparql-client.md) ^0.2.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.16 (latest) — 2017-02-02
- 1.0.15 — 2017-02-02
- 1.0.14 — 2017-02-02
- 1.0.13 — 2017-02-02
- 1.0.12 — 2017-01-30
- 1.0.11 — 2017-01-10
- 1.0.10 — 2017-01-10
- 1.0.9 — 2017-01-10
- 1.0.8 — 2016-12-22
- 1.0.7 — 2016-12-21
- 1.0.6 — 2016-12-15
- 1.0.5 — 2016-12-14
- 1.0.4 — 2016-12-13
- 1.0.3 — 2016-12-13
- 1.0.2 — 2016-12-13

## README

#ChirQL

###Simple, graph-oriented query language.

[![Build Status](https://travis-ci.org/weaverplatform/chirql.svg?branch=master)](https://travis-ci.org/weaverplatform/chirql)
[![Code Climate](https://codeclimate.com/github/weaverplatform/chirql/badges/gpa.svg)](https://codeclimate.com/github/weaverplatform/chirql)
[![codecov](https://codecov.io/gh/weaverplatform/chirql/badge.svg)](https://codecov.io/gh/weaverplatform/chirql)
[![npm version](https://badge.fury.io/js/chirql.svg)](http://badge.fury.io/js/chirql)


<!-- [![Test Coverage](https://codeclimate.com/github/weaverplatform/chirql/badges/coverage.svg)](https://codeclimate.com/github/weaverplatform/chirql/coverage) -->
## Installation:
```bash
npm i chirql --save
```

## Syntax

wrap everything in outer braces:
```js
{
  //include query criteria here
}
```
get an individual property by its predicate:
```js
{
  rdf:type
}
```
get a value property by it's predicate:
```js
{
  <rdfs:label>
}
```
constrain results by object id/value:
```javascript
{
  rdf:type(lib:Painter)          // ?s rdf:type http://test.tester.org/library#Painter
  <rdfs:label>(Pablo Picasso)    // ?s rdfs:label "Pablo Picasso"^^<http://www.w3.org/2001/XMLSchema#string>
}
```
constrain results by root id value:
```
(ins:individualID){
  rdf:type
  rdfs:label
}
```
supports nesting:
```js
{

  rdf:type(lib:GreatGrandparent)

  hasChild {
    rdf:type(lib:Grandparent)

    hasChild {
      rdf:type(lib:Parent)

      hasChild {
        rdf:type(lib:Child)

      }
    }
  }
}
```
####Usage
```js
ChirQL = require('chirql')

//optional namespace-prefix handler
namespaces = [
  { prefix: 'lib:', namespace: 'http://test.tester.org/library#' },
  { prefix: 'ins:', namespace: 'http://test.tester.org/instance#' },
]

chirQLr = new ChirQL('YOUR_DATABASE_QUERY_LANGUAGE', 'http://your.database.url', namespaces)

chirQLr.runQuery("
{
  <lib:hasName(Pablo Picasso)>
  <lib:hasAge>
  lib:hasSpouse {
    <lib:hasName>(OlgaKhoklova)
    <lib:hasAge>
    lib:hasProfession
  }
}
").then((res)->
  //do something
)
```

####Sequence

This query gets transpiled into the specified query language (currently, only sparql is supported),


eg:
```sparql
select ?root,?prop1,?prop2,?prop3,?prop4 where {

?root lib:hasName "Picasso"^^<http://www.w3.org/2001/XMLSchema#string> .
?root lib:hasAge ?prop1 .
?root lib:hasSpouse ?prop2 .
ins:OlgaKhoklova lib:hasName "OlgaKhoklova"^^<http://www.w3.org/2001/XMLSchema#string> .
ins:OlgaKhoklova lib:hasAge ?prop3 .
ins:OlgaKhoklova lib:hasProfession ?prop4 .

}
```
Finally the results are serialised into an object matching the construction of the initial chirql query

eg:
```js
[{
  'lib:hasName' : ['Pablo Picasso']
  'lib:hasAge' : ['65']
  'lib:hasSpouse' : [{
    'lib:hasName' : ['Olga Khokhlova']
    'lib:hasAge' : ['53']
    'lib:hasProfession' : ['lib:BalletDancer']
    }]
  }]
}]
```

#TODO:

- implement Cypher query manager

- add features for limit, sortby, etc.

---
_Source: https://npm.io/package/chirql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
