From 1309e462efc4a7bbdf538e9d209133c1b3c138a6 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 25 Oct 2018 22:22:55 +0200 Subject: Added authentication and post endpoint --- src/models/posts.model.js | 28 ++++++++++++++++++++++++++++ src/models/users.model.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/models/posts.model.js create mode 100644 src/models/users.model.js (limited to 'src/models') diff --git a/src/models/posts.model.js b/src/models/posts.model.js new file mode 100644 index 0000000..e46117c --- /dev/null +++ b/src/models/posts.model.js @@ -0,0 +1,28 @@ +// See http://docs.sequelizejs.com/en/latest/docs/models-definition/ +// for more of what you can do here. +const Sequelize = require('sequelize'); +const DataTypes = Sequelize.DataTypes; + +module.exports = function (app) { + const sequelizeClient = app.get('sequelizeClient'); + const posts = sequelizeClient.define('posts', { + text: { + type: DataTypes.STRING, + allowNull: false + } + }, { + hooks: { + beforeCount(options) { + options.raw = true; + } + } + }); + + // eslint-disable-next-line no-unused-vars + posts.associate = function (models) { + // Define associations here + // See http://docs.sequelizejs.com/en/latest/docs/associations/ + }; + + return posts; +}; diff --git a/src/models/users.model.js b/src/models/users.model.js new file mode 100644 index 0000000..407e712 --- /dev/null +++ b/src/models/users.model.js @@ -0,0 +1,36 @@ +// See http://docs.sequelizejs.com/en/latest/docs/models-definition/ +// for more of what you can do here. +const Sequelize = require('sequelize'); +const DataTypes = Sequelize.DataTypes; + +module.exports = function (app) { + const sequelizeClient = app.get('sequelizeClient'); + const users = sequelizeClient.define('users', { + + email: { + type: DataTypes.STRING(126), + allowNull: false, + unique: true + }, + password: { + type: DataTypes.STRING(126), + allowNull: false + }, + + + }, { + hooks: { + beforeCount(options) { + options.raw = true; + } + } + }); + + // eslint-disable-next-line no-unused-vars + users.associate = function (models) { + // Define associations here + // See http://docs.sequelizejs.com/en/latest/docs/associations/ + }; + + return users; +}; -- cgit v1.2.3