use standard decorator fields in lpEvents

This commit is contained in:
Barry Gitarts 2019-01-17 12:16:17 -05:00
parent 2bc3e5fd34
commit 5b086ab1e8
2 changed files with 14 additions and 11 deletions

View File

@ -1,19 +1,17 @@
import { Model } from '@nozbe/watermelondb' import { Model } from '@nozbe/watermelondb'
import { action } from '@nozbe/watermelondb/decorators' import { action, field } from '@nozbe/watermelondb/decorators'
import { fieldGenerator } from '../utils/db'
export default class LpEvent extends Model { export default class LpEvent extends Model {
constructor(...args) {
super(...args)
const field = fieldGenerator(this)
field('event_id', 'eventId')
field('address')
field('event')
field('block_number', 'blockNumber')
}
static table = 'lp_events' static table = 'lp_events'
@field('address') address
@field('event_id') eventId
@field('event') event
@field('block_number') blockNumber
@action async addEvent(data) { @action async addEvent(data) {
return await this.create(lpEvent => { return await this.create(lpEvent => {
const { event, address, id, blockNumber } = data const { event, address, id, blockNumber } = data
@ -24,3 +22,4 @@ export default class LpEvent extends Model {
}) })
} }
} }

View File

@ -6,3 +6,7 @@ export const fieldGenerator = self => (column, name) => {
configurable: true configurable: true
}) })
} }
export function initialize(target, name, descriptor) {
descriptor.initializer = true
}