1.1.29 • Published 7 months ago

@vinctus/oql v1.1.29

Weekly downloads
257
License
ISC
Repository
-
Last release
7 months ago

Table of Contents generated with DocToc

OQL

npm (scoped) GitHub Release Date GitHub GitHub last commit GitHub issues Snyk Vulnerabilities for npm scoped package npm bundle size (scoped) GitHub Workflow Status

Object Query Language (OQL) is a simple relational database query language inspired by GraphQL and SQL, but designed to be translated query-for-query into database engine specific SQL, with identical behaviour across supported engines.

Full library documentation can be found here.

Overview

OQL is a language for querying a relational database. The query syntax draws inspiration from GraphQL and is similar, but with many differences. Some capabilities missing from GraphQL have been added, and some capabilities found in GraphQL have a different syntax. We believe that much of conventional SQL syntax is still preferable to creating a completely new syntax for every single feature of the query language. However, whereas SQL can be seen as a "low level" relational query language, OQL takes a higher level Entity-Relationship (ER) Model view of the database.

The name "OQL" refers to both a software library, and a query language implemented within that library. The OQL library provides support for data retrieval (via the OQL query language), and a query builder for constructing queries step by step in your code. There are also class methods for performing all kinds of mutations, including mutations that support the ER model view of the database. Furthermore, query and mutation operations all abide by the supplied ER data model.

Some features of the OQL language include:

  • similar to GraphQL in that query results have exactly the structure requested in the query (i.e., you get what you ask for).
  • uses a very simple Entity-Relationship model description of the database
  • works with the PostgreSQL database system
  • designed to work with existing databases without having to change the database at all

Installation

TypeScript/JavaScript

There is a Node.js module available through the npm registry.

Install using the npm install command:

npm install @vinctus/oql

TypeScript declarations are included in the package.

Scala.js

There is a Scala.js library available through Github Packages.

Add the following lines to your build.sbt:

externalResolvers += "OQL" at "https://maven.pkg.github.com/vinctustech/oql"

libraryDependencies += "com.vinctus" %%% "-vinctus-oql" % "1.1.29"

Compile / npmDependencies ++= Seq(
  "pg" -> "8.10.0",
  "@types/pg" -> "8.6.6",
  "source-map-support" -> "0.5.21",
  "big.js" -> "6.1.1",
  "@types/big.js" -> "6.1.3"
)

Usage

Generally, using OQL in a project has the following form:

import { OQL } from '@vinctus/oql'

const oql = new OQL(<data model>, <host>, <port>, <database>, <user>, <password>, <ssl>, <idleTimeoutMillis>, <max>)

oql.queryMany(<query>).then((<result>: any) => <handle result>)

where host, port, database, user, password, ssl, idleTimeoutMillis, and max are the connection pool (PoolConfig) parameters for the Postgres database you are querying.

data model describes the parts of the database available for querying. It's not necessary to describe every field of every table in the database, only what is being retrieved with OQL. However, primary keys of tables that are being queried should always be included, even if you're not interested in retrieving the primary keys themselves.

query is the OQL query string.

handle result is your result array handling code. The result object will be predictably structured according to the query.

Tutorial

You can follow a fully explained tutorial example here.

API

Full API documentation can be found here.

Examples

Several examples are given here.

Tests

Requirements

  • Git (for cloning)
  • Java 11+
  • sbt (for building and running tests)

Setup PostgreSQL

To run the unit test, you will need to get PostgreSQL running in a docker container:

docker pull postgres
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 postgres

The PostgreSQL client (psql) should be installed. If necessary, it can be installed with the command

sudo apt-get install postgresql-client

Clone the repository

At the shell terminal go to the folder where the sources will be downloaded, referred to as dev-path/, and type

git git@github.com:vinctustech/oql.git

This will create folder dev-path/oql.

Build the test database

Type

cd oql/test

sh start

sh tests

sh build

The last few lines of output should be

CREATE TABLE
ALTER TABLE
INSERT 0 4
INSERT 0 4

Run tests

Type

cd ..
sbt test

You should see

[info] All tests passed.

License

OQL uses the commercial friendly open source ISC license.

1.2.0

8 months ago

1.1.29

7 months ago

1.1.28

7 months ago

1.2.1

8 months ago

1.1.27

7 months ago

1.1.26

8 months ago

1.1.25

8 months ago

1.2.0-alpha.8

8 months ago

1.2.0-alpha.6

8 months ago

1.2.0-alpha.7

8 months ago

1.2.0-alpha.4

8 months ago

1.2.0-alpha.5

8 months ago

1.2.0-alpha.2

8 months ago

1.2.0-alpha.3

8 months ago

1.2.0-alpha.1

8 months ago

1.1.3-pre.1

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.24

1 year ago

1.1.0-pre.26

1 year ago

1.1.0-pre.25

1 year ago

1.1.0-pre.9

2 years ago

1.1.0-pre.8

2 years ago

1.1.0-pre.16

2 years ago

1.1.0-pre.15

2 years ago

1.1.0-pre.14

2 years ago

1.1.0-pre.13

2 years ago

1.1.0-pre.12

2 years ago

1.1.0-pre.11

2 years ago

1.1.0-pre.10

2 years ago

1.1.0-pre.18

2 years ago

1.1.0-pre.17

2 years ago

1.1.0-pre.24

2 years ago

1.1.0-pre.23

2 years ago

1.1.0-pre.22

2 years ago

1.1.0-pre.21

2 years ago

1.1.0-pre.20

2 years ago

1.1.0-alpha.7

2 years ago

1.1.0-alpha.2

2 years ago

1.1.0-alpha.5

2 years ago

1.1.0-alpha.6

2 years ago

1.1.0-alpha.3

2 years ago

1.1.0-alpha.4

2 years ago

1.0.0

2 years ago

1.1.0-alpha.1

2 years ago

1.0.0-pre.11

3 years ago

1.0.0-pre.13

3 years ago

1.0.0-pre.12

3 years ago

1.0.0-pre.10

3 years ago

1.0.0-pre.9

3 years ago

1.0.0-pre.8

3 years ago

1.0.0-pre.7

3 years ago

1.0.0-pre.6

3 years ago

1.0.0-pre.5

3 years ago

1.0.0-pre.4

3 years ago

1.0.0-pre.1

3 years ago

1.0.0-RC.4.2

3 years ago

1.1.0-scope

3 years ago

1.1.0-scope.1

3 years ago

1.0.0-RC.4.1

3 years ago

1.0.0-RC.4

3 years ago

1.0.0-RC.3.25

3 years ago

1.0.0-RC.3.24

3 years ago

1.0.0-RC.3.23

3 years ago

1.0.0-RC.3.20

3 years ago

1.0.0-RC.3.21

3 years ago

1.0.0-RC.3.22

3 years ago

1.0.0-RC.3.19

3 years ago

1.0.0-RC.3.17

3 years ago

1.0.0-RC.3.18

3 years ago

1.0.0-RC.3.15

3 years ago

1.0.0-RC.3.16

3 years ago

1.0.0-RC.3.14

3 years ago

1.0.0-RC.2

3 years ago

1.0.0-RC.1

3 years ago

1.0.0-RC.3.2

3 years ago

1.0.0-RC.3.3

3 years ago

1.0.0-RC.3.4

3 years ago

0.1.65

3 years ago

0.1.66

3 years ago

0.1.63

3 years ago

0.1.64

3 years ago

0.1.62

3 years ago

0.1.61

3 years ago

0.1.35

3 years ago

0.1.36

3 years ago

0.1.34

3 years ago

0.1.31

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.16

3 years ago

0.1.13

3 years ago

0.1.10

3 years ago

0.1.12

3 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.2-snapshot.1

3 years ago

0.1.2-snapshot.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

4 years ago

0.1.0-snapshot.9

4 years ago

0.1.0-snapshot.8

4 years ago

0.1.0-snapshot.7

4 years ago

0.1.0-snapshot.6

4 years ago

0.1.0-snapshot.5

4 years ago

0.1.0-snapshot.4

4 years ago

0.1.0-snapshot.3

4 years ago

0.1.0-snapshot.2

4 years ago

0.1.0-snapshot.1

4 years ago

0.1.0-beta.2

4 years ago

0.1.0-beta.1

4 years ago

0.1.0-alpha.59

4 years ago

0.1.0-alpha.56

4 years ago

0.1.0-alpha.58

4 years ago

0.1.0-alpha.57

4 years ago

0.1.0-alpha.54

4 years ago

0.1.0-alpha.53

4 years ago

0.1.0-alpha.52

4 years ago

0.1.0-alpha.50

4 years ago

0.1.0-alpha.51

4 years ago

0.1.0-alpha.49

4 years ago

0.1.0-alpha.48

4 years ago

0.1.0-alpha.47

4 years ago

0.1.0-alpha.46

4 years ago

0.1.0-alpha.45

4 years ago

0.1.0-alpha.43

4 years ago

0.1.0-alpha.44

4 years ago

0.1.0-alpha.41

4 years ago

0.1.0-alpha.42

4 years ago

0.1.0-alpha.40

4 years ago

0.1.0-alpha.38

4 years ago

0.1.0-alpha.39

4 years ago

0.1.0-alpha.36

4 years ago

0.1.0-alpha.37

4 years ago

0.1.0-alpha.34

4 years ago

0.1.0-alpha.33

4 years ago

0.1.0-alpha.35

4 years ago

0.1.0-alpha.32

4 years ago

0.1.0-alpha.31

4 years ago

0.1.0-alpha.30

4 years ago

0.1.0-alpha.29

4 years ago

0.1.0-alpha.28

4 years ago

0.1.0-alpha.25

4 years ago

0.1.0-alpha.27

4 years ago

0.1.0-alpha.26

4 years ago

0.1.0-alpha.24

4 years ago

0.1.0-alpha.23

4 years ago

0.1.0-alpha.21

4 years ago

0.1.0-alpha.20

4 years ago

0.1.0-alpha.22

4 years ago

0.1.0-alpha.19

4 years ago

0.1.0-alpha.18

4 years ago

0.1.0-alpha.17

4 years ago

0.1.0-alpha.16

4 years ago

0.1.0-alpha.14

4 years ago

0.1.0-alpha.15

4 years ago

0.1.0-alpha.13

4 years ago

0.1.0-alpha.12

4 years ago

0.1.0-alpha.10

4 years ago

0.1.0-alpha.11

4 years ago

0.1.0-alpha.9

4 years ago

0.1.0-alpha.8

4 years ago

0.1.0-alpha.7

4 years ago

0.1.0-alpha.6

4 years ago

0.1.0-alpha.5

4 years ago

0.1.0-alpha.4

4 years ago