Propagate bulk helper document generic (#1606)

This commit is contained in:
Tomas Della Vedova
2021-12-16 16:45:48 +01:00
committed by GitHub
parent 194614564a
commit dbfc8fc4d1
2 changed files with 10 additions and 2 deletions

View File

@ -42,6 +42,11 @@ const dataset = [
{ user: 'tyrion', age: 39 }
]
interface Document {
user: string
age: number
}
test('bulk index', t => {
t.test('datasource as array', t => {
t.test('Should perform a bulk request', async t => {
@ -65,11 +70,12 @@ test('bulk index', t => {
node: 'http://localhost:9200',
Connection: MockConnection
})
const result = await client.helpers.bulk({
const result = await client.helpers.bulk<Document>({
datasource: dataset.slice(),
flushBytes: 1,
concurrency: 1,
onDocument (doc) {
t.type(doc.user, 'string') // testing that doc is type of Document
return {
index: { _index: 'test' }
}