From cd0c8c8afcef9dd5e413105653d98f7802569a0d Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Tue, 15 Jan 2019 13:32:55 -0500 Subject: [PATCH] add initial db schema and models --- app/dapp.js | 3 +++ app/db.js | 5 ++++- app/model/lpEvents.js | 10 ++++++++++ app/model/schema.js | 9 ++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 app/model/lpEvents.js diff --git a/app/dapp.js b/app/dapp.js index 46f6437..ab40248 100644 --- a/app/dapp.js +++ b/app/dapp.js @@ -11,6 +11,7 @@ import { FundingContext } from './context' import { cancelProfile } from './utils/fundProfiles' import MainCointainer from './components/MainCointainer' import { getTransfersMemo } from './selectors/pledging' +import database from './db' const { getNetworkType } = web3.eth.net @@ -41,6 +42,8 @@ class App extends React.Component { const allLpEvents = await getAllLPEvents() const vaultEvents = await getAllVaultEvents() const transfers = getTransfersMemo({ allLpEvents }) + const lpCollection = database.collections.get('lp_events') + console.log({lpCollection}) this.setState({ account, network, diff --git a/app/db.js b/app/db.js index 4233cd2..ffac034 100644 --- a/app/db.js +++ b/app/db.js @@ -2,6 +2,7 @@ import { Database } from '@nozbe/watermelondb' import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs' import schema from './model/schema' +import LpEvent from './model/lpEvents' const adapter = new LokiJSAdapter({ schema, @@ -10,7 +11,9 @@ const adapter = new LokiJSAdapter({ const database = new Database({ adapter, modelClasses: [ - // Post, // ⬅️ You'll add Models to Watermelon here + LpEvent ], actionsEnabled: true, }) + +export default database diff --git a/app/model/lpEvents.js b/app/model/lpEvents.js new file mode 100644 index 0000000..8896fb2 --- /dev/null +++ b/app/model/lpEvents.js @@ -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 + +} diff --git a/app/model/schema.js b/app/model/schema.js index 54a2177..064f4fb 100644 --- a/app/model/schema.js +++ b/app/model/schema.js @@ -3,6 +3,13 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb' export default appSchema({ version: 1, tables: [ - // tableSchemas go here... + tableSchema({ + name: 'lp_events', + columns: [ + { name: 'address', type: 'string' }, + { name: 'event', type: 'string' }, + { name: 'event_id', type: 'string' }, + ] + }) ] })