New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

millenniumdb-driver

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

millenniumdb-driver

The official MillenniumDB driver for JavaScript

latest
Source
npmnpm
Version
1.7.11
Version published
Weekly downloads
11
1000%
Maintainers
1
Weekly downloads
 
Created
Source

MillenniumDB driver for JavaScript (Browser and Node.js)

npm Latest Release npm downloads License

Installation - npm

npm install millenniumdb-driver

Then you can require the MillenniumDB object module:

var MillenniumDB = require('millenniumdb-driver');

Installation - browser

Make the MillenniumDB object available globally with:

<!-- Direct reference non-minified -->
<script src="/lib/browser/millenniumdb-driver.js"></script>
<!-- Direct reference minified -->
<script src="/lib/browser/millenniumdb-driver.min.js"></script>

<!-- unpkg CDN non-minified -->
<script src="https://unpkg.com/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.js"></script>
<!-- unpkg CDN minified -->
<script src="https://unpkg.com/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.min.js"></script>

<!-- jsDelivr CDN non-minified -->
<script src="https://cdn.jsdelivr.net/npm/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.js"></script>
<!-- jsDelivr CDN minified -->
<script src="https://cdn.jsdelivr.net/npm/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.min.js"></script>

Or use the ESM versions

<script type="module">
  // Direct reference non-minified
  import MillenniumDB from '/lib/browser/millenniumdb-driver.esm.js';
  // Direct reference minified
  import MillenniumDB from '/lib/browser/millenniumdb-driver.esm.min.js';
  // unpkg CDN non-minified
  import MillenniumDB from 'https://unpkg.com/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.esm.js';
  // unpkg CDN minified
  import MillenniumDB from 'https://unpkg.com/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.esm.min.js';
  // jsDelivr CDN non-minified
  import MillenniumDB from 'https://cdn.jsdelivr.net/npm/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.esm.js';
  // jsDelivr CDN minified
  import MillenniumDB from 'https://cdn.jsdelivr.net/npm/millenniumdb-driver@latest/lib/browser/millenniumdb-driver.esm.min.js';
</script>

Usage

Creating a Driver instance

First you must create a Driver instance:

const url = '<URL for the MillenniumDB server>';
const driver = MillenniumDB.driver(url)

When you are done with the driver, you should close it before exiting the application.

driver.close();

Usually you would like to have a single Driver instance in your application.

Acquiring a Session

For sending queries to the MillenniumDB server, you must acquire a session instance:

const session = driver.session();

Then you can send queries through your session

const query = 'MATCH (?from)-[:?type]->(?to) RETURN * LIMIT 10';
const result = session.run(query);

Consuming results

The alternatives for consuming results must never be mixed because it would generate undefined behavior on your client and/or server. It is important to mention that the session must be closed when your operations are done.

Streaming API

This is the preferred way to consume the results, as it is the only that does not hold all the results in memory, it just streams it to an observer object provided by the user. The observer must implement the following methods:

  • onVariables: First event trigerred, just once. It will return the variable names of the query. Optionally the second argument can be passed and it will receive the QueryPreamble, useful for query cancellation.
  • onRecord: Subsequent events triggered for each record available in the query result. It will return a Record object.
  • onSuccess: Trigerred at the end of the query execution. It will return a summary for the query. No more events are triggered afterwards.
  • onError: Trigerred if an error occurs during the query execution. It will return an error. No more events are triggered afterwards. This could even happen before receiving the onVariables event.
result.subscribe({
  onVariables: (variables) => {
    console.log('The variables are:', variables);
  },
  onRecord: (record) => {
    // Do something with each record
  },
  onSuccess: (summary) => {
    console.log('Summary:', summary);
    session.close();
  },
  onError: (error) => {
    console.error('Error:', error);
    session.close();
  },
});

Promise-based API with async/await syntax

const variables = await result.variables();
const records = await result.records();
const summary = await result.summary();

Promise-based API with .then(), .catch(), .finally() syntax

// catch/finally are ommited for brevity

result.variables().then((variables) => {
    console.log('The variables are:', variables);
});

result.records().then((records) => {
    for (const record of records) {
        // Do something with each record
    }
});

result.summary().then((summary) => {
    console.log('Summary', summary);
});

Keywords

millenniumdb

FAQs

Package last updated on 20 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts