nl_tokens: Insert object to table . The object will be appended with the property id which uses timestamp as value . There are 3 required arguments .
pl_tokens: function insertTableContent ( ) { let tableName = arguments [ 0 ] ; var fname = '' ; var callback ; var tableRow ; if ( arguments . length === 3 ) { callback = arguments [ 2 ] ; fname = path . join ( userData , arguments [ 0 ] + '.json' ) ; tableRow = arguments [ 1 ] ; } else if ( arguments . length === 4 ) { fname = path . join ( arguments [ 1 ] , arguments [ 0 ] + '.json' ) ; callback = arguments [ 3 ] ; tableRow = arguments [ 2 ] ; } let exists = fs . existsSync ( fname ) ; if ( exists ) { // Table | json parsed let table = JSON . <mask> ( fs . readFileSync ( fname ) ) ; let date = new Date ( ) ; let id = date . getTime ( ) ; tableRow [ 'id' ] = id ; table [ tableName ] . push ( tableRow ) ; try { fs . writeFileSync ( fname , JSON . stringify ( table , null , 2 ) , ( err ) => { } ) callback ( true , "Object written successfully!" ) ; return ; } catch ( e ) { callback ( false , "Error writing object." ) ; return ; } } callback ( false , "Table/json file doesn't exist!" ) ; return ; }