add initial db schema and models

This commit is contained in:
Barry Gitarts 2019-01-15 13:32:55 -05:00
parent 933dd9f105
commit cd0c8c8afc
4 changed files with 25 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import { FundingContext } from './context'
import { cancelProfile } from './utils/fundProfiles' import { cancelProfile } from './utils/fundProfiles'
import MainCointainer from './components/MainCointainer' import MainCointainer from './components/MainCointainer'
import { getTransfersMemo } from './selectors/pledging' import { getTransfersMemo } from './selectors/pledging'
import database from './db'
const { getNetworkType } = web3.eth.net const { getNetworkType } = web3.eth.net
@ -41,6 +42,8 @@ class App extends React.Component {
const allLpEvents = await getAllLPEvents() const allLpEvents = await getAllLPEvents()
const vaultEvents = await getAllVaultEvents() const vaultEvents = await getAllVaultEvents()
const transfers = getTransfersMemo({ allLpEvents }) const transfers = getTransfersMemo({ allLpEvents })
const lpCollection = database.collections.get('lp_events')
console.log({lpCollection})
this.setState({ this.setState({
account, account,
network, network,

View File

@ -2,6 +2,7 @@ import { Database } from '@nozbe/watermelondb'
import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs' import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs'
import schema from './model/schema' import schema from './model/schema'
import LpEvent from './model/lpEvents'
const adapter = new LokiJSAdapter({ const adapter = new LokiJSAdapter({
schema, schema,
@ -10,7 +11,9 @@ const adapter = new LokiJSAdapter({
const database = new Database({ const database = new Database({
adapter, adapter,
modelClasses: [ modelClasses: [
// Post, // ⬅️ You'll add Models to Watermelon here LpEvent
], ],
actionsEnabled: true, actionsEnabled: true,
}) })
export default database

10
app/model/lpEvents.js Normal file
View File

@ -0,0 +1,10 @@
import { Model } from '@nozbe/watermelondb'
export default class LpEvent extends Model {
static table = 'lp_events'
@field('event_id') eventId
@field('address') address
@field('event') event
}

View File

@ -3,6 +3,13 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb'
export default appSchema({ export default appSchema({
version: 1, version: 1,
tables: [ tables: [
// tableSchemas go here... tableSchema({
name: 'lp_events',
columns: [
{ name: 'address', type: 'string' },
{ name: 'event', type: 'string' },
{ name: 'event_id', type: 'string' },
]
})
] ]
}) })