New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@douglasgabr/cypher-builder

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@douglasgabr/cypher-builder

Fluent CQL builder for Neo4j

  • 4.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
110
decreased by-25.68%
Maintainers
0
Weekly downloads
 
Created
Source

cypher-builder

Fluent CQL Builder for Neo4j

Node.js Package

Installation

npm install @douglasgabr/cypher-builder

or

yarn add @douglasgabr/cypher-builder

Usage

Type inference (required for typescript projects)

First, you must create a *.d.ts file in your project, in order to type the possible nodes, relationships and their properties.

// neo4j-types.d.ts
import '@douglasgabr/cypher-builder';

declare module '@douglasgabr/cypher-builder' {
  export interface CypherBuilderNodes {
    User: {
      id: string;
    };
  }

  export interface CypherBuilderRelationships {
    KNOWS: {
      level: 'friendship' | 'colleague';
    };
  }
}

That will enable your IDE (tested only in VSCode) to suggest values for your node labels, relationship types and its properties.

Node Label suggestion:

node label suggestion

Node Properties suggestion:

node properties suggestion

Relationship Type suggestion:

relationship type suggestion

Example

import { Builder } from '@douglasgabr/cypher-builder';

const queryBuilder = new Builder()
  .match((match) => {
    match
      .node('person', 'Person', { name: 'Alice' })
      .relationship('either', 'KNOWS')
      .node('friend', 'Person'),
  })
  .where((where) => where.and('friend.age', '>=', 18))
  .return('person', 'friend');
const { query, parameters } = queryBuilder.buildQueryObject();

query:

MATCH (person:Person{ name: $person_name })-[:KNOWS]-(friend:Person)
WHERE friend.age >= $friend_age
RETURN person, friend

parameters:

{
  person_name: 'Alice',
  friend_age: 18
}

Keywords

FAQs

Package last updated on 28 Nov 2024

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