# gremlin-helper

> A wrapper around the gremlin client to introduce model validation and other useful functionality to use within a web api.

Latest version **0.0.25-alpha** (published 2018-02-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install gremlin-helper
pnpm add gremlin-helper
yarn add gremlin-helper
bun add gremlin-helper
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.25-alpha |
| Published | 2018-02-27 |
| First published | 2018-02-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 39.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jacob Ebey |
| Maintainers | jacob-ebey |
| Keywords | Gremlin, Node, Express |

## Links

- npm: https://www.npmjs.com/package/gremlin-helper
- Repository: https://github.com/jacob-ebey/gremlin-helper
- Homepage: https://github.com/jacob-ebey/gremlin-helper#readme
- Issues: https://github.com/jacob-ebey/gremlin-helper/issues
- npm.io page: https://npm.io/package/gremlin-helper

## Dependencies (2)

- [bcrypt](https://npm.io/package/bcrypt.md) ^1.0.3
- [google-libphonenumber](https://npm.io/package/google-libphonenumber.md) ^3.0.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.0.25-alpha (latest) — 2018-02-27
- 0.0.24-alpha — 2018-02-26
- 0.0.23-alpha — 2018-02-26
- 0.0.22-alpha — 2018-02-26
- 0.0.21-alpha — 2018-02-26
- 0.0.20-alpha — 2018-02-25
- 0.0.19-alpha — 2018-02-25
- 0.0.18-alpha — 2018-02-25
- 0.0.17-alpha — 2018-02-25
- 0.0.16-alpha — 2018-02-24
- 0.0.15-alpha — 2018-02-24
- 0.0.14-alpha — 2018-02-24
- 0.0.13-alpha — 2018-02-24
- 0.0.12-alpha — 2018-02-24
- 0.0.11-alpha — 2018-02-24
- … 10 more at https://npm.io/package/gremlin-helper/versions

## README

A wrapper around the gremlin client to introduce model validation and other useful functionality to use within a web api.

## Features

- Model schemas
- Retrieve models in a workable format
- Mockable for testing

## Getting Started

Install from NPM: https://www.npmjs.com/package/gremlin-helper

```
> npm install --save gremlin gremlin-helper
```

Create a vertex model

```typescript
import { Vertex } from 'gremlin-helper';

interface IPerson {
  name: string;
  phone?: string;
}

const PersonVertex = new Vertex<IPerson>({
  label: 'user',
  props: {
    name: {
      type: 'string',
      required: true
    },
    phone: 'string'
  }
});
```

Add some pre-commit operations

```typescript
import { Ops } from 'gremlin-helper';

PersonVertex.ops = {
  phone: Ops.merge(
    Ops.validatePhone,
    Ops.formatPhone
  )
}
```

Create an edge model

```typescript
import { Edge } from 'gremlin-helper';

const FriendEdge = new Edge({ label: 'friend' })
```

Create a client

```typescript
import { createClient } from 'gremlin';
import { Client } from 'gremlin-helper';

const client = new Client(createClient, config);
```

Create some people

```typescript
const person1 = await client.addVAsync(PersonVertex, {
  name: 'Person 1',
  phone: '800273 8255'
});

const person2 = await client.addVAsync(PersonVertex, {
  name: 'Person 2'
});

const person3 = await client.addVAsync(PersonVertex, {
  name: 'Person 3'
});
```

Create some friend edges

```typescript
// Person 1 friends person 2
await client.addEAsync(FriendEdge, person1.id, person2.id);
// Person 3 friends person 1
await client.addEAsync(FriendEdge, person3.id, person1.id);
```

Get all of person1 friends
```typescript
import { QueryBuilder } from 'gremlin-helper';

// Build a query to get all people that have friended, or have been
// friended by person1
const query = new QueryBuilder()
  .getAllV(PersonVertex)
  .hasE(FriendEdge)
  .toOrFrom(PersonVertex, person1.id);

const friends = await client.executeAsync(PersonVertex, query);
```

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