diff options
| author | Adam Soltys <[email protected]> | 2018-02-12 19:35:34 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-02-12 19:35:34 -0800 |
| commit | d41cd218ff1ebab07f2bf8e84ffa0ca7deeb1a04 (patch) | |
| tree | a4de7e44acd90bd0f55a856917008aff4793473d /db.js | |
| parent | cbf91f53e6c97cdb76c293c46813fbc9a74f47e5 (diff) | |
| download | coinos-server-d41cd218ff1ebab07f2bf8e84ffa0ca7deeb1a04.tar.gz coinos-server-d41cd218ff1ebab07f2bf8e84ffa0ca7deeb1a04.zip | |
generate lightning deposit address on user create
Diffstat (limited to 'db.js')
| -rw-r--r-- | db.js | 82 |
1 files changed, 42 insertions, 40 deletions
@@ -44,56 +44,58 @@ const db = new Sequelize( const gqlfields = {} const gqltypes = {} -const p = new Promise((resolve, reject) => { - return auto.run(() => { - Object.keys(tables).forEach((k) => { - let t = tables[k] - let fields = {} +const p = (lnrpc) => { + return new Promise((resolve, reject) => { + return auto.run(() => { + Object.keys(tables).forEach((k) => { + let t = tables[k] + let fields = {} - Object.keys(auto.tables[t]).forEach(f => { - let isKey = f === 'id' - let rawtype = auto.tables[t][f].type.toLowerCase() - let type = Sequelize.STRING + Object.keys(auto.tables[t]).forEach(f => { + let isKey = f === 'id' + let rawtype = auto.tables[t][f].type.toLowerCase() + let type = Sequelize.STRING - if (rawtype.match(/^int/)) type = Sequelize.INTEGER - if (rawtype.match(/^date/)) type = Sequelize.DATE + if (rawtype.match(/^int/)) type = Sequelize.INTEGER + if (rawtype.match(/^date/)) type = Sequelize.DATE - fields[f] = { - type: type, - field: f, - primaryKey: isKey, - autoIncrement: isKey, - } - }) + fields[f] = { + type: type, + field: f, + primaryKey: isKey, + autoIncrement: isKey, + } + }) - db[k] = db.define(k, fields, { tableName: t }) + db[k] = db.define(k, fields, { tableName: t }) - let typefields = {} - let options = {} + let typefields = {} + let options = {} - gqltypes[t] = new GraphQLObjectType({ - name: t, - desc: t, - fields: Object.assign(typefields, attributeFields(db[k])), + gqltypes[t] = new GraphQLObjectType({ + name: t, + desc: t, + fields: Object.assign(typefields, attributeFields(db[k])), + }) + + gqlfields[t] = { + type: new GraphQLList(gqltypes[t]), + args: Object.assign({}, defaultArgs(db[k]), defaultListArgs()), + resolve: resolver(db[k], options), + } }) - gqlfields[t] = { - type: new GraphQLList(gqltypes[t]), - args: Object.assign({}, defaultArgs(db[k]), defaultListArgs()), - resolve: resolver(db[k], options), - } - }) + db.gqlschema = new GraphQLSchema({ + query: new GraphQLObjectType({ + name: 'RootQueryType', + fields: gqlfields + }), + mutation: require('./mutations')(db, gqltypes, lnrpc) + }) - db.gqlschema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'RootQueryType', - fields: gqlfields - }), - mutation: require('./mutations')(db, gqltypes) + resolve(db) }) - - resolve(db) }) -}) +} module.exports = p |
