File tree 3 files changed +45
-1
lines changed
3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import TransactionStatement from './Statements/TransactionStatement';
5
5
import UpdateStatement from './Statements/UpdateStatement' ;
6
6
import DeleteStatement from './Statements/DeleteStatement' ;
7
7
import AttachIndexStatement from './Statements/AttachIndexStatement' ;
8
+ import TruncateStatement from './Statements/TruncateStatement' ;
8
9
9
10
export default class QueryBuilder {
10
11
// protected type: QueryType;
@@ -55,6 +56,10 @@ export default class QueryBuilder {
55
56
return new AttachIndexStatement ( this . connection , diskIndex ) ;
56
57
}
57
58
59
+ public truncate ( rtIndex : string ) : TruncateStatement {
60
+ return new TruncateStatement ( this . connection , rtIndex ) ;
61
+ }
62
+
58
63
get transaction ( ) : TransactionStatement {
59
64
return new TransactionStatement ( this . connection ) ;
60
65
}
Original file line number Diff line number Diff line change @@ -46,4 +46,4 @@ export default class AttachIndexStatement {
46
46
execute ( ) : Promise < any > {
47
47
return this . connection . execute ( this . generate ( ) , [ ] ) ;
48
48
}
49
- }
49
+ }
Original file line number Diff line number Diff line change
1
+ import ClientInterface from '../ClientInterface' ;
2
+
3
+ /**
4
+ * TRUNCATE RTINDEX rtindex [WITH RECONFIGURE]
5
+ */
6
+ export default class TruncateStatement {
7
+ protected reconfigure : boolean = false ;
8
+
9
+ public constructor ( protected connection : ClientInterface , protected rtIndex : string ) { }
10
+
11
+ /**
12
+ * When RECONFIGURE option is used new tokenization, morphology,
13
+ * and other text processing settings from config take effect
14
+ * right after index got cleared. This allows to make operations atomic.
15
+ */
16
+ public withReconfigure ( ) : TruncateStatement {
17
+ this . reconfigure = true ;
18
+ return this ;
19
+ }
20
+
21
+ /**
22
+ * Generates the string statement.
23
+ */
24
+ generate ( ) : string {
25
+ let expression : string = `TRUNCATE RTINDEX ${ this . rtIndex } ` ;
26
+ if ( this . reconfigure ) {
27
+ expression += ` WITH RECONFIGURE` ;
28
+ }
29
+
30
+ return expression ;
31
+ }
32
+
33
+ /**
34
+ * Run the query and returns a promise that can be accepted or rejected.
35
+ */
36
+ execute ( ) : Promise < any > {
37
+ return this . connection . execute ( this . generate ( ) , [ ] ) ;
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments