diff --git a/.travis.yml b/.travis.yml index 61260c2..7ab746e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ before_install: before_script: - composer dump-autoload - cd tests - - $TRAVIS_BUILD_DIR/tests/run.sh + - $TRAVIS_BUILD_DIR/__tests__/run.sh - npm install script: npm run test diff --git a/README.md b/README.md index 949928a..0ec22b3 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,15 @@ connection.getQueryBuilder() }); ``` +### REPLACE +```javascript +const document = { + id: 1, + content: 'this is the first post for the blog...', + title: 'First post' +}; +``` + ### UPDATE ```javascript const document = { @@ -143,7 +152,7 @@ const document = { }; const insertDocumentAndCommit = async (doc) => { - await connection.getQueryBuilder().transaction().begin(); + await connection.getQueryBuilder().transaction.begin(); connection.getQueryBuilder() .insert('my_rtindex', doc) @@ -155,7 +164,7 @@ const insertDocumentAndCommit = async (doc) => { console.log(err); }); - await connection.getQueryBuilder().transaction().commit(); + await connection.getQueryBuilder().transaction.commit(); return true; } diff --git a/src/QueryBuilder.ts b/src/QueryBuilder.ts index e2af0f4..fb78c02 100644 --- a/src/QueryBuilder.ts +++ b/src/QueryBuilder.ts @@ -46,6 +46,10 @@ export default class QueryBuilder { return new DeleteStatement(this.connection, index); } + public optimizeIndex(index: string): Promise { + return this.connection.query(`OPTIMIZE INDEX ${index}`); + } + get transaction(): TransactionStatement { return new TransactionStatement(this.connection); }