Skip to content

Commit

Permalink
(#3) RELOAD INDEX implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
SiroDiaz committed Jun 30, 2019
1 parent 372ce91 commit 8ba55ea
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import UpdateStatement from './Statements/UpdateStatement';
import DeleteStatement from './Statements/DeleteStatement';
import AttachIndexStatement from './Statements/AttachIndexStatement';
import TruncateStatement from './Statements/TruncateStatement';
import ReloadIndexStatement from './Statements/ReloadIndexStatement';

export default class QueryBuilder {
// protected type: QueryType;
Expand Down Expand Up @@ -60,6 +61,10 @@ export default class QueryBuilder {
return new TruncateStatement(this.connection, rtIndex);
}

public reloadIndex(index: string): ReloadIndexStatement {
return new ReloadIndexStatement(this.connection, index);
}

get transaction(): TransactionStatement {
return new TransactionStatement(this.connection);
}
Expand Down
38 changes: 38 additions & 0 deletions src/Statements/ReloadIndexStatement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import ClientInterface from '../ClientInterface';

/**
* RELOAD INDEX idx [ FROM '/path/to/index_files' ]
*/
export default class ReloadIndexStatement {
protected path: string;

public constructor(protected connection: ClientInterface, protected index: string) {}

/**
* Specifies the path of the index file. This is an option method.
*/
public from(path: string): ReloadIndexStatement {
this.path = path;

return this;
}

/**
* Generates the string statement.
*/
generate(): string {
let expression: string = `RELOAD INDEX ${this.index}`;
if (this.path !== undefined) {
expression += ` FROM '${this.path}'`;
}

return expression;
}

/**
* Run the query and returns a promise that can be accepted or rejected.
*/
execute(): Promise<any> {
return this.connection.execute(this.generate(), []);
}
}

0 comments on commit 8ba55ea

Please sign in to comment.