Files
old-spike/models/power_datum.js

53 lines
1018 B
JavaScript
Raw Normal View History

2016-01-26 19:42:30 -06:00
import {
GraphQLFloat,
GraphQLInt,
GraphQLNonNull,
GraphQLObjectType
} from 'graphql';
import {
fromGlobalId,
2016-01-27 20:15:09 -06:00
globalIdField
2016-01-26 19:42:30 -06:00
} from 'graphql-relay';
2016-01-27 20:15:09 -06:00
import DB from "./../config/database";
import {nodeInterface} from './../lib/node.relay';
2016-01-26 19:42:30 -06:00
/**
* Define your own types here
*/
2016-01-27 20:15:09 -06:00
var PowerDatum = DB.sequelize.define('PowerDatum', {
2016-01-26 19:42:30 -06:00
id: {
2016-01-27 20:15:09 -06:00
type: DB.Sequelize.INTEGER,
2016-01-26 19:42:30 -06:00
primaryKey: true,
autoIncrement: true // Automatically gets converted to SERIAL for postgres
},
2016-01-31 11:35:22 -06:00
time: DB.Sequelize.DATE,
2016-01-27 20:15:09 -06:00
power: DB.Sequelize.FLOAT
2016-01-26 19:42:30 -06:00
}, {
2016-01-31 11:35:22 -06:00
tableName: "power_data",
2016-01-26 19:42:30 -06:00
instanceMethods: {
},
classMethods: {
2016-01-27 20:15:09 -06:00
associate: ()=>{
PowerDatum.belongsTo(DB.House);
2016-01-26 19:42:30 -06:00
}
}
});
PowerDatum.graphql_type = new GraphQLObjectType({
2016-01-27 20:15:09 -06:00
name: 'PowerDatum',
2016-01-26 19:42:30 -06:00
description: 'A person who uses our app',
fields: () => ({
id: globalIdField('PowerDatum'),
time: GraphQLInt,
power: GraphQLFloat
}),
interfaces: [nodeInterface],
});
2016-01-27 20:15:09 -06:00
PowerDatum.name = 'PowerDatum';
2016-01-26 19:42:30 -06:00
2016-01-27 20:15:09 -06:00
module.exports = PowerDatum;