diff options
| author | Adam Soltys <[email protected]> | 2018-03-15 22:13:42 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-03-15 22:13:42 -0700 |
| commit | 869b33813e72689c053ba8505c8806129ec3c7d5 (patch) | |
| tree | f3044c3aeaf23d08efd7425df83be6695f0f3715 /db.js | |
| parent | 79aeed9061db8b335e60bc4bee48571e717fa637 (diff) | |
| download | coinos-server-869b33813e72689c053ba8505c8806129ec3c7d5.tar.gz coinos-server-869b33813e72689c053ba8505c8806129ec3c7d5.zip | |
use payments table for in and out ln and onchain payments
Diffstat (limited to 'db.js')
| -rw-r--r-- | db.js | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -25,8 +25,7 @@ const auto = new SequelizeAuto( const tables = { User: 'users', - Transaction: 'transactions', - Invoice: 'invoices', + Payment: 'payments', } const db = new Sequelize( @@ -70,15 +69,32 @@ const p = (lnrpc) => { db[k] = db.define(k, fields, { tableName: t }) - if (t === 'invoices') { - db['Invoice'].belongsTo(db['User'], { + let typefields = {} + + let options = {} + + if (t === 'users') { + options = { + before: (findOptions, args, context) => { + findOptions.where = { id: context.user.id } + return findOptions + } + } + } + + if (t === 'payments') { + db['Payment'].belongsTo(db['User'], { as: 'user', foreignKey: 'user_id' }) - } - let typefields = {} - let options = {} + options = { + before: (findOptions, args, context) => { + findOptions.where = { user_id: context.user.id } + return findOptions + } + } + } gqltypes[t] = new GraphQLObjectType({ name: t, |
