aboutsummaryrefslogtreecommitdiffstats
path: root/db.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-01-05 18:39:30 -0800
committerAdam Soltys <[email protected]>2020-01-05 18:39:30 -0800
commitb0e279aff714164a01ece9d2d933e4649d3ad48c (patch)
tree2ceabc01f0e8f3f54e4f91ec4aed98bcc43c1488 /db.js
parent3b841f05921311cf149b7987d76738fcb053a52e (diff)
downloadcoinos-server-b0e279aff714164a01ece9d2d933e4649d3ad48c.tar.gz
coinos-server-b0e279aff714164a01ece9d2d933e4649d3ad48c.zip
queue on-chain payments
Diffstat (limited to 'db.js')
-rw-r--r--db.js40
1 files changed, 4 insertions, 36 deletions
diff --git a/db.js b/db.js
index b2372c89..c66bab30 100644
--- a/db.js
+++ b/db.js
@@ -1,22 +1,6 @@
const config = require("./config");
const Sequelize = require("sequelize");
const SequelizeAuto = require("sequelize-auto");
-const {
- resolver,
- defaultArgs,
- defaultListArgs,
- attributeFields
-} = require("graphql-sequelize");
-const {
- graphql,
- GraphQLSchema,
- GraphQLObjectType,
- GraphQLInputObjectType,
- GraphQLString,
- GraphQLInt,
- GraphQLNonNull,
- GraphQLList
-} = require("graphql");
const conf = config.db[process.env.NODE_ENV || "development"];
@@ -39,9 +23,6 @@ const db = new Sequelize(conf.database, conf.username, conf.password, {
dialectOptions: { multipleStatements: true }
});
-const gqlfields = {};
-const gqltypes = {};
-
const p = new Promise((resolve, reject) => {
return auto.run(() => {
Object.keys(tables).forEach(k => {
@@ -92,27 +73,14 @@ const p = new Promise((resolve, reject) => {
}
};
}
-
- 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)
- };
});
- db.gqlschema = new GraphQLSchema({
- query: new GraphQLObjectType({
- name: "RootQueryType",
- fields: gqlfields
- })
+ db["User"].hasMany(db["Payment"], {
+ as: "payments",
+ foreignKey: "user_id"
});
+
resolve(db);
});
});