From 4649ac45887a01a9ff6fe302ee14ad809652f2fe Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 25 Apr 2023 18:56:34 -0400 Subject: [PATCH] Adding functionality to interact with data Create model for the users but need to be able to interact with the table --- app.js | 7 +++++++ models.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 models.js diff --git a/app.js b/app.js index 7dc2f2f..c9441eb 100644 --- a/app.js +++ b/app.js @@ -1,3 +1,5 @@ +require('./models.js') + const express = require('express') const app = express() const port = 3000 @@ -9,7 +11,12 @@ app.post('/api/v1/user/new', (req, res) => { res.send('Posting') console.log(req.body) + // const usr = new User() + let username = req.body['username'] + + // usr.username = username + console.log(`Username: ${username}`) }) diff --git a/models.js b/models.js new file mode 100644 index 0000000..53d57f2 --- /dev/null +++ b/models.js @@ -0,0 +1,14 @@ +const mongoose = require('mongoose'); + +const Schema = mongoose.Schema; +const ObjectId = Schema.ObjectId; + +const User = new Schema({ + userID: { type: String }, + firstName: { type: String }, + lastName: { type: String }, + phoneNumber: { type: String }, + username: { type: String }, + password: { type: String }, + dateCreated: { type: Date, default: Date.now } +});