Skip to content

Commit

Permalink
#3 added OPTIMIZE INDEX
Browse files Browse the repository at this point in the history
  • Loading branch information
SiroDiaz committed Jun 6, 2019
1 parent 163ea76 commit 454f9d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand All @@ -155,7 +164,7 @@ const insertDocumentAndCommit = async (doc) => {
console.log(err);
});

await connection.getQueryBuilder().transaction().commit();
await connection.getQueryBuilder().transaction.commit();

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default class QueryBuilder {
return new DeleteStatement(this.connection, index);
}

public optimizeIndex(index: string): Promise<any> {
return this.connection.query(`OPTIMIZE INDEX ${index}`);
}

get transaction(): TransactionStatement {
return new TransactionStatement(this.connection);
}
Expand Down

0 comments on commit 454f9d1

Please sign in to comment.