# gremlin-template-string

> Generate Gremlin scripts with bound parameters using ES6 template strings

Latest version **2.0.0** (published 2016-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install gremlin-template-string
pnpm add gremlin-template-string
yarn add gremlin-template-string
bun add gremlin-template-string
```

## 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 | 2.0.0 |
| Published | 2016-02-26 |
| First published | 2015-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Jean-Baptiste Musso |
| Maintainers | jbmusso |
| Keywords | gremlin, tinkerpop, apache, graph, database, graphdb, query |

## Links

- npm: https://www.npmjs.com/package/gremlin-template-string
- Repository: https://github.com/jbmusso/gremlin-template-string
- Homepage: https://github.com/jbmusso/gremlin-template-string#readme
- Issues: https://github.com/jbmusso/gremlin-template-string/issues
- npm.io page: https://npm.io/package/gremlin-template-string

## 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

- 2.0.0 (latest) — 2016-02-26
- 1.0.0 — 2015-04-30

## README

# gremlin-template-string

Generate Gremlin scripts with bound parameters using ES6 template strings.

Gremlin is a graph database query language used by the [Apache TinkerPop](http://tinkerpop.incubator.apache.org/) framework.

Read the full Gremlin/TinkerPop3 documentation there: http://www.tinkerpop.com/docs/current/

## Install

```
$ npm install gremlin-template-string --save
```

Run tests with:
```
$ npm test
```

## Usage

The module exports a single function (*tag expression*) which allows you to tag an ES6 template template string.

It will return an object with two properties: 
* `script`: an escaped Gremlin string
* `params`: a map (Object) of bound parameters (ie `{p1: 'Foo', 'p2': 'Bar'}`)

## Example

```javascript
var gremlin = require('gremlin-template-string');

var who = 'Foobar';
var query = gremlin`
  g.V('name', ${who}).out('follows').name
`
// query.script === "\n  g.V('name', p1).out('follows').name\n"
// query.params.p1 === 'Foobar'
```

## Benefits

* easy multiline Gremlin queries
* syntax highlighting in IDE (Sublime Text)
* safer scripts (prevents Gremlin injections)
* faster scripts (bound parameters)

## Thanks

This library is heavily inspired by this blog post: http://www.ivc.com/blog/better-sql-strings-in-io-js-nodejs-part-2/. Thanks!

## Author
 - [@jbmusso](https://twitter.com/jbmusso)

# License

MIT

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