# cypher-promise

> A wrapper over node-cypher which is promise-based

Latest version **1.0.2** (published 2016-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install cypher-promise
pnpm add cypher-promise
yarn add cypher-promise
bun add cypher-promise
```

## 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.2 |
| Published | 2016-06-02 |
| First published | 2015-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | rangermauve |
| Maintainers | rangermauve |
| Keywords | cypher, promise, query, neo4j, graph |

## Links

- npm: https://www.npmjs.com/package/cypher-promise
- Repository: https://github.com/RangerMauve/cypher-promise
- Issues: https://github.com/RangerMauve/cypher-promise/issues
- npm.io page: https://npm.io/package/cypher-promise

## Dependencies (3)

- [par](https://npm.io/package/par.md) ^0.3.0
- [any-promise](https://npm.io/package/any-promise.md) ^0.1.0
- [node-cypher](https://npm.io/package/node-cypher.md) ^0.1.4

## 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.2 (latest) — 2016-06-02
- 1.0.1 — 2015-06-06
- 1.0.0 — 2015-01-09

## README

cypher-promise
==============

A wrapper over node-cypher which is promise-based. This uses [any-promise](https://www.npmjs.com/package/any-promise) so you're expected to install a promise library that's compatible.

```
    npm install --save cypher-promise
```

Example
-------

```javascript
// Require the module
var cypher = require("./");
var Promise = require("any-promise");

// Connect to a DB
var client = cypher("http://localhost:7474");

// Make a query
client.query("MATCH (n:Person) RETURN count(n)").then(log, err);

// Make batch queries
var multi = client.multi();

// This will let us easily build a bunch of queries to execute
var queries = [];
var index = 10;
var multi_query = "CREATE (n:Person{index:{index}}) RETURN count(n)";

while (index--) {
  // Build up the array of promises from the queries
  queries.push(multi.query(multi_query, {
    index: index
  }));
}

// Execute the batch
multi.exec().then(log.bind(null, "Multi executed"));

// Once all the promises resolve
Promise.all(queries).then(log, err);

function log(data) {
  console.log(data);
}

function err(data) {
  console.error("Error", data);
}
```

API
---

### `Cypher([connection_url],[connection_opts])`\`

This creates a new cypher `Client` for making queries.

#### arguments

-	[connection_url] {String}: This is the connection URL. If it is omitted,`http://localhost:7474` is used instead.
-	[connection_opts] {Object}: Please see the [node-cypher docs](https://github.com/objectundefined/node-cypher#createclientconnectionoptions-clientoptions-callback-) for what this should contain. It's an empty object by default.

### returns

A new instance of `Client`

### `Client.query(cypher_text,[parameters])`

Sends a new query and resolves to the result

#### arguments

-	cypher_text {String} A query written in Cypher to send to Neo4j
-	[parameters] {Object} Optional parameters to pass into the query. It's an empty object if not specified.

### returns

-	A `Promise` which resolves to the result of the query.

### `Client.multi()`

Creates a new `Batch` for making multiple queries to the server in one request.

#### returns

A new `Batch` instance

### `Batch.query(cypher_text,[parameters])`

Exact same API as `Client.query`, but it doesn't evaluate until you execute the batch

### `Batch.exec()`

This executes the batch and triggers all the query promises to resolve on success.

#### returns

A `Promise` which rejects if there was something wrong during the batch query.

Thanks
------

Special thanks to [Gabriel Lipson](https://github.com/objectundefined) for making [node-cypher](https://github.com/objectundefined/node-cypher).

License
-------

The MIT License (MIT)

Copyright (c) 2015 RangerMauve

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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