mirror of
https://github.com/linnovate/mean.git
synced 2025-12-08 19:56:03 +00:00
* feat: upgrade to Angular 13 * feat: switch to ESLint since TSLint has been deprecated * feat: upgrade outdated Node.js packages and Node version within the Dockerfile
39 lines
884 B
JavaScript
39 lines
884 B
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const UserSchema = new mongoose.Schema(
|
|
{
|
|
fullname: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
email: {
|
|
type: String,
|
|
required: true,
|
|
unique: true,
|
|
// Regexp to validate emails with more strict rules as added in tests/users.js which also conforms mostly with RFC2822 guide lines
|
|
match: [
|
|
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
'Please enter a valid email',
|
|
],
|
|
},
|
|
hashedPassword: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
createdAt: {
|
|
type: Date,
|
|
default: Date.now,
|
|
},
|
|
roles: [
|
|
{
|
|
type: String,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
versionKey: false,
|
|
}
|
|
);
|
|
|
|
module.exports = mongoose.model('User', UserSchema);
|