use standard decorator fields in lpEvents
This commit is contained in:
parent
2bc3e5fd34
commit
5b086ab1e8
|
@ -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 {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,7 @@ export const fieldGenerator = self => (column, name) => {
|
||||||
configurable: true
|
configurable: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function initialize(target, name, descriptor) {
|
||||||
|
descriptor.initializer = true
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue