Skip to content
Snippets Groups Projects
Commit beac154e authored by Dorus's avatar Dorus
Browse files

feat: created structure and query service

parent 54775349
No related branches found
No related tags found
No related merge requests found
import neo4j from 'neo4j-driver';
import { Neo4jConnection } from 'ts-common';
import { queryService } from '../queryService';
import * as fs from 'fs';
......@@ -6,24 +6,53 @@ import path from 'path';
import argv from "process"
import { createInterface } from 'readline';
const rl = createInterface({
input: process.stdin,
output: process.stdout,
});
function manualQuery(cypherQuery: string, outputFile: string) {
return `${cypherQuery} ${outputFile}`
}
function connectToDataBase(uri: string, username: string, password: string){
return `${uri} ${username} ${password}`
}
if (require.main === module) {
// Command-line args:
// 1st query,
// 2nd output file
const cypherQuery: string = process.argv[2] || 'MATCH (n) RETURN n LIMIT 10'; // Default query if none provided
const outputFile: string = process.argv[3] || 'output.json'; // Default output file if none provided
if (!cypherQuery || !outputFile) {
console.log('Please provide a valid Cypher query and output file name.');
process.exit(1);
// 1st uri,
// 2nd username
// 3rd password
// 4th output file
const uri: string = process.argv[1] || "bolt://localhost:7687"; // default neo4j port
const username: string = process.argv[2] || "username";
const password: string = process.argv[3] || "passowrd";
const driver = neo4j.driver(uri, neo4j.auth.basic(username, password));
const session = driver.session();
const outputFile: string = process.argv[4] || 'output.json'; // Default output file if none provided
while(true)
{
rl.question("Query: ", (cypherQuery) =>{
if (!cypherQuery || !outputFile) {
console.log('Please provide a valid Cypher query and output file name.');
process.exit(1);
}
let out: string = manualQuery(cypherQuery, outputFile);
console.log(out)
}
}
let out: string = manualQuery(cypherQuery, outputFile);
console.log(out)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment