Skip to content

Commit a6e7f66

Browse files
committed
- BREAKING CHANGE: replace default import with named import.
- upgrade dependencies - rename `query` to `body` in search method to avoid confusion
1 parent f6f795a commit a6e7f66

File tree

4 files changed

+214
-113
lines changed

4 files changed

+214
-113
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ yarn add aws-elasticsearch-model
1414

1515
```typescript
1616
import AWS from 'aws-sdk';
17-
import ElasticModel from 'aws-elasticsearch-model';
17+
import {ElasticModel} from 'aws-elasticsearch-model';
1818

1919
/*
2020
ElasticModel uses aws-sdk's default behaviour to obtain region + credentials from your environment.
@@ -61,7 +61,7 @@ Attach this lambda handler to your DynamoDB table and it will sync all the data
6161

6262
```typescript
6363
import {DynamoDBStreamEvent} from 'aws-lambda';
64-
import ElasticModel from 'aws-elasticsearch-model';
64+
import {ElasticModel} from 'aws-elasticsearch-model';
6565

6666
const elasticModel = new ElasticModel({
6767
host: 'https://my-aws-elasticsearch-domain.eu-west-1.es.amazonaws.com',

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,25 @@
5656
}
5757
},
5858
"devDependencies": {
59-
"@types/aws-lambda": "^8.10.39",
59+
"@types/aws-lambda": "^8.10.40",
6060
"@types/elasticsearch": "^5.0.36",
61-
"@types/faker": "^4.1.8",
61+
"@types/faker": "^4.1.9",
6262
"@types/http-aws-es": "^6.0.0",
63-
"@types/jest": "^24.0.25",
64-
"aws-lambda": "latest",
65-
"aws-sdk": "^2.597.0",
63+
"@types/jest": "^25.1.0",
64+
"aws-lambda": "1.0.5",
65+
"aws-sdk": "^2.610.0",
6666
"dotenv": "^8.2.0",
6767
"faker": "latest",
68-
"husky": "^3.1.0",
68+
"husky": "^4.2.1",
6969
"release-it": "^12.4.3",
70-
"tsdx": "^0.12.1",
70+
"tsdx": "^0.12.3",
7171
"tslib": "^1.10.0",
72-
"typescript": "^3.7.4"
72+
"typescript": "^3.7.5"
7373
},
7474
"dependencies": {
7575
"bodybuilder": "^2.2.20",
7676
"dynamodb-data-types": "^3.0.1",
77-
"elasticsearch": "^16.5.0",
77+
"elasticsearch": "16.6.0",
7878
"http-aws-es": "^6.0.0"
7979
}
8080
}

src/index.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface IElasticModelConfig {
6161
excludedFields?: string[];
6262
}
6363

64-
class ElasticModel<T extends Item> {
64+
export class ElasticModel<T extends Item> {
6565
client: Client;
6666
protected index: string;
6767
protected idField: string;
@@ -116,12 +116,12 @@ class ElasticModel<T extends Item> {
116116

117117
/**
118118
* Executes search query
119-
* @param query - search query
119+
* @param body - search request body
120120
*/
121-
async search(query: Query): Promise<ISearchResult<T>> {
121+
async search(body: Query): Promise<ISearchResult<T>> {
122122
const params = {
123123
index: this.index,
124-
body: query
124+
body
125125
};
126126
const response = await this.client.search<T>(params);
127127
let total: number;
@@ -230,5 +230,3 @@ class ElasticModel<T extends Item> {
230230
return this.client.indices.create(params);
231231
}
232232
}
233-
234-
export default ElasticModel;

0 commit comments

Comments
 (0)