1- const { chunk } = require ( " ../Util" ) ;
1+ const { chunk } = require ( ' ../Util' ) ;
22
33module . exports = ( ast , db ) => {
44 if ( ast . type . toLowerCase ( ) !== 'delete' ) throw new TypeError ( 'invalid query type' ) ;
@@ -7,33 +7,33 @@ module.exports = (ast, db) => {
77 if ( ! data [ table ] ) throw new Error ( `Table "${ table } " does not exist` ) ;
88
99 const point = { left : ast . where . left . value , op : ast . where . operator , right : ast . where . right . value } ;
10- if ( ! data [ table ] . keys . some ( x => x . column === point . left ) ) throw new Error ( `Column "${ set . col } " does not exists in table "${ table } "` ) ;
10+ if ( ! data [ table ] . keys . some ( ( x ) => x . column === point . left ) ) throw new Error ( `Column "${ set . col } " does not exists in table "${ table } "` ) ;
1111 const bin = binOp ( data [ table ] , point ) ;
1212 if ( bin . index < 0 ) return ;
1313
14- bin . data . forEach ( d => {
14+ bin . data . forEach ( ( d ) => {
1515 data [ table ] . data . splice ( data [ table ] . data . indexOf ( d ) , 1 ) ;
1616 } ) ;
1717
1818 db . write ( data ) ;
19- }
19+ } ;
2020
2121function binOp ( data , clause ) {
2222 switch ( clause . op ) {
23- case "=" :
23+ case '=' :
2424 const child = chunk ( data . data , 2 ) ;
25- const fnx = m => m . key === clause . left && m . data === clause . right ;
26- const fn = x => x . find ( fnx ) ;
25+ const fnx = ( m ) => m . key === clause . left && m . data === clause . right ;
26+ const fn = ( x ) => x . find ( fnx ) ;
2727
2828 try {
2929 const data = child . find ( fn ) ;
3030 if ( ! data ) throw new Error ( `Could not verify operation "${ clause . left } = ${ clause . right } "` ) ;
3131 return {
3232 data : data ,
33- index : child . findIndex ( fn )
33+ index : child . findIndex ( fn ) ,
3434 } ;
3535 } catch {
3636 throw new Error ( `Could not verify operation "${ clause . left } = ${ clause . right } "` ) ;
3737 }
3838 }
39- }
39+ }
0 commit comments