From 5b086ab1e8ac0fbfed659ae825e3c76bb832ff07 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Thu, 17 Jan 2019 12:16:17 -0500 Subject: [PATCH] use standard decorator fields in lpEvents --- app/model/lpEvents.js | 21 ++++++++++----------- app/utils/db.js | 4 ++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/model/lpEvents.js b/app/model/lpEvents.js index cafc271..06708aa 100644 --- a/app/model/lpEvents.js +++ b/app/model/lpEvents.js @@ -1,19 +1,17 @@ import { Model } from '@nozbe/watermelondb' -import { action } from '@nozbe/watermelondb/decorators' -import { fieldGenerator } from '../utils/db' +import { action, field } from '@nozbe/watermelondb/decorators' 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' + @field('address') address + + @field('event_id') eventId + + @field('event') event + + @field('block_number') blockNumber + @action async addEvent(data) { return await this.create(lpEvent => { const { event, address, id, blockNumber } = data @@ -24,3 +22,4 @@ export default class LpEvent extends Model { }) } } + diff --git a/app/utils/db.js b/app/utils/db.js index da50dc0..b08301b 100644 --- a/app/utils/db.js +++ b/app/utils/db.js @@ -6,3 +6,7 @@ export const fieldGenerator = self => (column, name) => { configurable: true }) } + +export function initialize(target, name, descriptor) { + descriptor.initializer = true +}