introduce TxResult

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov
2021-10-13 18:46:48 +02:00
parent e080f6e724
commit d75d17bfec
19 changed files with 127 additions and 92 deletions
+5 -3
View File
@@ -14,7 +14,7 @@
// limitations under the License.
//
import type { Doc, Ref } from '@anticrm/core'
import type { Doc, Ref, TxResult } from '@anticrm/core'
import type { FullTextAdapter, IndexedDoc, SearchQuery } from '@anticrm/server-core'
import { Client } from '@elastic/elasticsearch'
@@ -58,7 +58,7 @@ class ElasticAdapter implements FullTextAdapter {
return hits.map(hit => hit._source)
}
async index (doc: IndexedDoc): Promise<void> {
async index (doc: IndexedDoc): Promise<TxResult> {
console.log('eastic: index', doc)
if (doc.data === undefined) {
const resp = await this.client.index({
@@ -81,9 +81,10 @@ class ElasticAdapter implements FullTextAdapter {
console.log('resp', resp)
console.log('error', (resp.meta as any)?.body?.error)
}
return {}
}
async update (id: Ref<Doc>, update: Record<string, any>): Promise<void> {
async update (id: Ref<Doc>, update: Record<string, any>): Promise<TxResult> {
const resp = await this.client.update({
index: this.db,
id,
@@ -92,6 +93,7 @@ class ElasticAdapter implements FullTextAdapter {
}
})
console.log('update', resp)
return {}
}
}