Adding functionality to interact with data
Create model for the users but need to be able to interact with the table
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
require('./models.js')
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const app = express()
|
const app = express()
|
||||||
const port = 3000
|
const port = 3000
|
||||||
@@ -9,7 +11,12 @@ app.post('/api/v1/user/new', (req, res) => {
|
|||||||
res.send('Posting')
|
res.send('Posting')
|
||||||
console.log(req.body)
|
console.log(req.body)
|
||||||
|
|
||||||
|
// const usr = new User()
|
||||||
|
|
||||||
let username = req.body['username']
|
let username = req.body['username']
|
||||||
|
|
||||||
|
// usr.username = username
|
||||||
|
|
||||||
console.log(`Username: ${username}`)
|
console.log(`Username: ${username}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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 }
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user