File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 22test
33.github
44.gitignore
5+ TODO.md
Original file line number Diff line number Diff line change 1010 "url" : " https://github.com/ariflogs/SQL-to-NoSQL"
1111 },
1212 "homepage" : " https://github.com/ariflogs/SQL-to-NoSQL" ,
13- "main" : " dist/index.js " ,
13+ "main" : " dist/index.mjs " ,
1414 "scripts" : {
1515 "dev" : " tsc -w" ,
16- "start" : " tsc && node dist/index.js " ,
16+ "start" : " tsc && node dist/index.mjs " ,
1717 "build" : " npx prettier . --check && tsc" ,
1818 "test" : " echo \" Error: no test specified\" && exit 1" ,
1919 "pretty" : " npx prettier . --write"
3737 "dependencies" : {
3838 "mongodb" : " ^6.1.0"
3939 }
40- }
40+ }
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export class SqlToNoSql {
2121 }
2222
2323 const q = parseQuery ( query ) ;
24- this . client = await connect ( this . config . connection ) ;
2524
2625 const filters : {
2726 [ key : string ] : {
@@ -47,9 +46,14 @@ export class SqlToNoSql {
4746 } ;
4847
4948 try {
50- await this . client . connect ( ) ;
49+ if ( ! this . client ) {
50+ this . client = await connect ( this . config . connection ) ;
51+ await this . client . connect ( ) ;
52+ }
53+
5154 const db = this . client . db ( ) ;
5255 const collection = db . collection ( mongoQuery . collection ) ;
56+
5357 const data = await collection [ mongoQuery [ q . command ] ] (
5458 mongoQuery . query ,
5559 ) . toArray ( ) ;
You can’t perform that action at this time.
0 commit comments