2019-01-15 18:32:55 +00:00
|
|
|
import { Model } from '@nozbe/watermelondb'
|
2019-01-15 22:29:02 +00:00
|
|
|
import { action } from '@nozbe/watermelondb/decorators'
|
2019-01-16 18:57:07 +00:00
|
|
|
import { fieldGenerator } from '../utils/db'
|
2019-01-15 18:32:55 +00:00
|
|
|
|
|
|
|
export default class LpEvent extends Model {
|
2019-01-16 18:57:07 +00:00
|
|
|
constructor(...args) {
|
|
|
|
super(...args)
|
|
|
|
const field = fieldGenerator(this)
|
|
|
|
field('event_id', 'eventId')
|
|
|
|
field('address')
|
|
|
|
field('event')
|
|
|
|
field('block_number', 'blockNumber')
|
|
|
|
}
|
2019-01-15 18:32:55 +00:00
|
|
|
|
2019-01-16 18:57:07 +00:00
|
|
|
static table = 'lp_events'
|
2019-01-15 22:29:02 +00:00
|
|
|
|
|
|
|
@action async addEvent(data) {
|
|
|
|
return await this.create(lpEvent => {
|
|
|
|
const { event, address, id, blockNumber } = data
|
|
|
|
lpEvent.eventId = id
|
|
|
|
lpEvent.address = address
|
|
|
|
lpEvent.event = event
|
|
|
|
lpEvent.blockNumber = blockNumber
|
|
|
|
})
|
|
|
|
}
|
2019-01-15 18:32:55 +00:00
|
|
|
}
|