Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ramprasathmk committed Jan 22, 2025
1 parent 47e48a1 commit bee9c6e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/usersController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const User = require('../models/user')

/**
* Error handling middleware wrapper for `usersController`
*/
const asyncHandler = (fn) => {
return (req, res, next) => {
fn(req, res, next).catch(next)
}
}
34 changes: 34 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const mongoose = require('mongoose')
const arrType = mongoose.Types.Array

/**
* User Schema {
* username: String, password: String, details: JSON | Object
* }
*/
const userSchema = new mongoose.Schema({
username: {
type: String,
unique: true,
},
password: {
type: String,
default: 'abc'
},
details: {
type: JSON | Object,
default: {}
},
poemId: {
type: arrType,
default: []
},
createdAt: {
type: Date,
default: Date.now
}
})

const User = mongoose.model('User', userSchema)

module.exports = User

0 comments on commit bee9c6e

Please sign in to comment.