liquid-funding/app/model/lpEvents.js

30 lines
674 B
JavaScript
Raw Normal View History

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