@@ -319,22 +319,27 @@ export const assertSchema = ({
319319 schema,
320320 dropExisting = true ,
321321 debug = false ,
322- sessionParams = { }
322+ sessionParams = { } ,
323+ context = { }
323324} ) => {
324325 const statement = schemaAssert ( { schema, dropExisting } ) ;
325326 const executeQuery = driver => {
326327 const session = driver . session ( sessionParams ) ;
327328 return session
328- . writeTransaction ( tx =>
329- tx . run ( statement ) . then ( result => {
330- if ( debug === true ) {
331- const recordsJSON = result . records . map ( record => record . toObject ( ) ) ;
332- recordsJSON . sort ( ( lhs , rhs ) => lhs . label < rhs . label ) ;
333- console . table ( recordsJSON ) ;
334- }
335- return result ;
336- } ) ,
337- context . transactionConfig )
329+ . writeTransaction (
330+ tx =>
331+ tx . run ( statement ) . then ( result => {
332+ if ( debug === true ) {
333+ const recordsJSON = result . records . map ( record =>
334+ record . toObject ( )
335+ ) ;
336+ recordsJSON . sort ( ( lhs , rhs ) => lhs . label < rhs . label ) ;
337+ console . table ( recordsJSON ) ;
338+ }
339+ return result ;
340+ } ) ,
341+ context . transactionConfig
342+ )
338343 . finally ( ( ) => session . close ( ) ) ;
339344 } ;
340345 return executeQuery ( driver ) ;
@@ -345,7 +350,8 @@ export const searchSchema = async ({
345350 schema,
346351 debug = false ,
347352 sessionParams = { } ,
348- dropExisting = true
353+ dropExisting = true ,
354+ context = { }
349355} ) => {
350356 const session = driver . session ( sessionParams ) ;
351357 // drop all search indexes, given they cannot be updated via a second CALL to createNodeIndex
@@ -355,15 +361,16 @@ export const searchSchema = async ({
355361 RETURN TRUE
356362 ` ;
357363 if ( dropExisting ) {
358- const dropResult = await session . writeTransaction ( tx =>
359- tx . run ( dropStatement ) . then ( result => {
360- if ( debug === true ) {
361- console . log (
362- `\n[searchSchema] Search indexes dropped using Cypher:${ dropStatement } `
363- ) ;
364- }
365- return true ;
366- } ) ,
364+ const dropResult = await session . writeTransaction (
365+ tx =>
366+ tx . run ( dropStatement ) . then ( result => {
367+ if ( debug === true ) {
368+ console . log (
369+ `\n[searchSchema] Search indexes dropped using Cypher:${ dropStatement } `
370+ ) ;
371+ }
372+ return true ;
373+ } ) ,
367374 context . transactionConfig
368375 ) ;
369376 if ( ! dropResult ) {
@@ -375,15 +382,16 @@ export const searchSchema = async ({
375382 const createStatement = schemaSearch ( { schema } ) ;
376383 if ( createStatement ) {
377384 return await session
378- . writeTransaction ( tx =>
379- tx . run ( createStatement ) . then ( result => {
380- if ( debug === true ) {
381- console . log (
382- `[searchSchema] Search indexes created using Cypher:\n${ createStatement } \n`
383- ) ;
384- }
385- return true ;
386- } ) ,
385+ . writeTransaction (
386+ tx =>
387+ tx . run ( createStatement ) . then ( result => {
388+ if ( debug === true ) {
389+ console . log (
390+ `[searchSchema] Search indexes created using Cypher:\n${ createStatement } \n`
391+ ) ;
392+ }
393+ return true ;
394+ } ) ,
387395 context . transactionConfig
388396 )
389397 . finally ( ( ) => session . close ( ) ) ;
0 commit comments