Skip to content

Commit

Permalink
fix createObject method (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmptyInfinity authored Jul 2, 2021
1 parent 3e0a383 commit 5cc8b9e
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 4,609 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module.exports = {
"max-len": ["error", { "code": 180 }],
"no-param-reassign": 0,
"guard-for-in": "off",
"no-return-assign": 0
"no-return-assign": 0,
"no-prototype-builtins": 0
},
'settings': {
'import/extensions': ['.js','.jsx','.ts','.tsx'],
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The official Elastic.io object-storage client.

## Usage

Note: All the code snippets written in Typescript
Note: All the code snippets written in Typescript

### Create client
```
Expand All @@ -19,15 +19,18 @@ const objectStorage = new ObjectStorageWrapper(this);

The method has the following signature:
```
async createObject(data: object, queryKey?: string, queryValue?: string, ttl?: number)
async createObject(data: object, headers?: Header[], ttl?: number)
```
where
- data - object data to create. *Required*
- queryKey, queryValue - searchable field (see below in `Get objects by query parameter` section). *Optional*, but if queryKey is specified, queryValue must be specified as well.
- headers - array of objects `{ key: string, value: string }`, current maximum - 5 items. Where `key` - searchable field name (see below in `Get objects by query parameter` section), must be unique for whole array, if specified - `value` must be specified as well; `value` - searchable field value, if specified - `key` must be specified as well. *Optional*
- ttl - configurable object's time to live, milliseconds. *Optional*

```
const obj = await objectStorage.createObject(data, somequeriablefieldKey, somequeriablefieldValue, 60000);
const obj = await objectStorage.createObject(data);
const obj = await objectStorage.createObject(data, [], 100000);
const obj = await objectStorage.createObject(data, [{key: 'someQueriableFieldKey', value: 'someQueriableFieldValue'}], 60000);
const obj = await objectStorage.createObject(data, [{key: 'anotherQueriableFieldKey', value: 'anotherQueriableFieldValue'}], 60000);
```

### Read operations
Expand Down
Loading

0 comments on commit 5cc8b9e

Please sign in to comment.