liquid-funding/app/model/lpEvents.js

30 lines
674 B
JavaScript
Raw Normal View History

2019-01-15 18:32:55 +00:00
import { Model } from '@nozbe/watermelondb'
2019-01-19 18:12:36 +00:00
import { action, field, json } from '@nozbe/watermelondb/decorators'
2019-01-15 18:32:55 +00:00
2019-01-19 18:12:36 +00:00
const sanitizeValues = json => json
2019-01-15 18:32:55 +00:00
export default class LpEvent extends Model {
2019-01-16 18:57:07 +00:00
static table = 'lp_events'
2019-01-15 22:29:02 +00:00
@field('address') address
@field('event_id') eventId
@field('event') event
@field('block_number') blockNumber
2019-01-19 18:12:36 +00:00
@json('return_values', sanitizeValues) returnValues
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
}