Skip to content

FalkorDB/falkordb-ts

Repository files navigation

Tests Coverage License Discord Twitter

falkordb-ts

Try Free

falkordb is a FalkorDB client for Node.js.

Installation

Start a falkordb via docker:

docker run -p 6379:6379 -it falkordb/falkordb:latest

To install node falkordb, simply:

npm install falkordb

Usage

Basic Example

import { FalkorDB } from 'falkordb';

const db = await FalkorDB.connect({
    username: 'myUsername',
    password: 'myPassword',
    socket: {
        host: 'localhost',
        port: 6379
    }
})

console.log('Connected to FalkorDB')

const graph = db.selectGraph('myGraph')

await graph.query(`CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
        (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}),
        (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})`)

result = await graph.query(`MATCH (r:Rider)-[:rides]->(t:Team) 
                            WHERE t.name = $name RETURN r.name`, 
                            {params: {name: 'Yamaha'}})
                            
console.log(result) // Valentino Rossi

console.log(await db.list())
console.log(await db.info())

db.close()

To learn more about Cypher query language check: https://docs.falkordb.com/cypher/

.close()

Forcibly close a client's connection to FalkorDB immediately. Calling close will not send further pending commands to the Redis server, or wait for or parse outstanding responses.

await client.close();

License

This repository is licensed under the "MIT" license. See LICENSE.