UNPKG

@ocap/indexdb-elasticsearch

Version:
37 lines (30 loc) 778 B
/* eslint-disable no-underscore-dangle */ const { formatTxBeforeInsert } = require('@ocap/indexdb/lib/util'); const ESIndex = require('./base'); const getParams = require('../model/tx'); const { getTableName } = require('../util'); class Tx extends ESIndex { constructor(db) { super({ name: getTableName(db.config.prefix, 'tx'), docId: 'hash', client: db.client, http: db.http, indexParams: getParams(), }); } _insert(row) { return super._insert(formatTxBeforeInsert(row)); } batchInsert(rows) { return super.batchInsert(rows.map((x) => formatTxBeforeInsert(x))); } async _get(key) { const doc = await super._get(key); if (doc) { delete doc.assets; } return doc; } } module.exports = Tx;