add Profiles model to database

This commit is contained in:
Barry Gitarts 2019-01-17 14:18:09 -05:00
parent 5b086ab1e8
commit 8c71a9a945
3 changed files with 15 additions and 16 deletions

View File

@ -18,11 +18,11 @@ export const batchAddProfiles = async profiles => {
const { addr, canceled, commitTime, type, name, url, idProfile } = data const { addr, canceled, commitTime, type, name, url, idProfile } = data
profile.addr = addr profile.addr = addr
profile.canceled = canceled profile.canceled = canceled
profile.commitTime = commitTime profile.commitTime = Number(commitTime)
profile.type = type profile.type = type
profile.name = name profile.name = name
profile.url = url profile.url = url
profile.idProfile = idProfile profile.idProfile = Number(idProfile)
}) })
}) })
console.log({batch}) console.log({batch})

View File

@ -3,6 +3,7 @@ import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs'
import schema from './model/schema' import schema from './model/schema'
import LpEvent from './model/lpEvents' import LpEvent from './model/lpEvents'
import Profiles from './model/profiles'
const adapter = new LokiJSAdapter({ const adapter = new LokiJSAdapter({
schema, schema,
@ -11,7 +12,8 @@ const adapter = new LokiJSAdapter({
const database = new Database({ const database = new Database({
adapter, adapter,
modelClasses: [ modelClasses: [
LpEvent LpEvent,
Profiles
], ],
actionsEnabled: true, actionsEnabled: true,
}) })

View File

@ -1,20 +1,17 @@
import { Model } from '@nozbe/watermelondb' import { Model } from '@nozbe/watermelondb'
import { fieldGenerator } from '../utils/db' import { field } from '@nozbe/watermelondb/decorators'
export default class Profiles extends Model { export default class Profiles extends Model {
constructor(...args) {
super(...args)
const field = fieldGenerator(this)
field('addr')
field('canceled')
field('commit_time', 'commitTime')
field('type')
field('name')
field('url')
field('id_profile', 'idProfile')
}
static table = 'profiles' static table = 'profiles'
} @field('addr') addr
@field('canceled') canceled
@field('commit_time') commitTime
@field('type') type
@field('name') name
@field('url') url
@field('id_profile') idProfile
}