Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gremlin-template-string

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gremlin-template-string

Generate Gremlin scripts with bound parameters using ES6 template strings

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

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

License

MIT

Keywords

FAQs

Package last updated on 30 Apr 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc