Git Product home page Git Product logo

pgx-client-js's Introduction

PGX JavaScript Client

Use the PGX JavaScript client to communicate with the PGX server from your JavaScript application. More information about PGX can be found on the Oracle Technology Network (OTN) page and the PGX documentation website.

Prerequisites

The PGX client needs a PGX server that it can connect to.

  1. Download and extract PGX 2.7.0 Server from Oracle Technology Network (OTN).
  2. Set enable_tls and enable_client_authentication to false in conf/server.conf.
  3. Set allow_local_filesystem to true in conf/pgx.conf.
  4. Run ./bin/start-server.

You can open http://localhost:7007/version to verify the PGX server is up and running. Once the PGX server is up and running you can use this library to connect to the server from JavaScript.

Usage

Add pgx-client-js as a dependency of your project:

npm install oracle/pgx-client-js

Require the PGX JS client module in your project:

const pgx = require('pgx-client-js');

Connect to the PGX server:

let p = pgx.connect('http://localhost:7007');

Load a graph and print the number of vertices and edges:

p.then(function (session) {
  return session.readGraphWithProperties({
    uri: 'examples/graphs/sample.adj',
    format: 'adj_list',
    vertex_props: [{
      name: 'prop1',
      type: 'int'
    }],
    edge_props: [{
      name: 'cost',
      type: 'double'
    }],
    separator: ' ',
    loading: {},
    error_handling: {}
  })
}).then(function (graph) {
  console.log("Vertices: " + graph.numVertices);
  console.log("Edges: " + graph.numEdges);
});

Testing

Run npm test to run the tests (see test/).

Known issues

Compatibility

The PGX JS client is compatible with PGX 2.7.0. Because PGX 3.0.0 made big changes in the REST API, many methods are no longer compatible. A small number of methods (listed below) have been updated to work with PGX 19.1. We invite contributions that make the PGX JS client compatible with newer versions of PGX. The REST API used by PGX 3.2.0 is documented in swagger.json. The easiest way to browse this documentation is by loading swagger.json into the Swagger Editor.

The following methods have been updated to work with PGX 19.1:

  • session.readGraphWithProperties
  • session.getGraph
  • graph.queryPgql
  • resultSet.getResults
  • resultSet.getResultSetElements
  • resultSet.getResultSet
  • session.postSession
  • session.delSession

Big numbers

JavaScript numbers are all floating point, stored according to the IEEE 754 standard. The PGX server might return numbers that fall out of IEEE 754 integer precision range. For example, the JSON may contain the number 9223372036854775807, but the result of JSON.parse is 9223372036854776000. The BigInt type provides a way to represent larger numbers. We invite contributions that make the PGX JS client support large numbers.

Resources

pgx-client-js's People

Contributors

martijndwars avatar

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.