Commit ba8ab9c0 authored by Tobinsk's avatar Tobinsk
Browse files

Merge branch '4-ensure-index-exists' into 'master'

Generate an unique index for place.uri

Closes #4

See merge request !8
parents 824c9469 a19f663e
......@@ -3,6 +3,7 @@ import {Core} from 'geolinker-common';
import Neo4jStreamWriter from './neo4j-stream-writer';
import {v1 as neo4j} from 'neo4j-driver';
import KafkaAvro = require('kafka-avro');
import Session from 'neo4j-driver/types/v1/session';
/**
* To trigger this you need to set the KAFKA_AVRO_LOG_LEVEL
......@@ -47,6 +48,13 @@ kafka.init().then(() => {
core.getNconf().get('neo4j:config:user'),
core.getNconf().get('neo4j:config:password'),
));
/**
* Add index and constraint to DB. If the index exists the query is ignored
* todo: not 100% sure if this is the right place to define the indexes
*/
await driver.session().run('CREATE CONSTRAINT ON (p:Place) ASSERT p.uri IS UNIQUE');
/**
* pipe the stream from kafka fo neo4j
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment