Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
beac154e
Commit
beac154e
authored
4 months ago
by
Dorus
Browse files
Options
Downloads
Patches
Plain Diff
feat: created structure and query service
parent
54775349
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/manual_mode/manualMode.ts
+40
-11
40 additions, 11 deletions
src/manual_mode/manualMode.ts
with
40 additions
and
11 deletions
src/manual_mode/manualMode.ts
+
40
−
11
View file @
beac154e
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
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment