summary refs log tree commit diff
path: root/src/db/schemas/user.js
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-01 08:04:30 +0200
committerRory& <root@rory.gay>2025-06-01 08:04:30 +0200
commit0ca7c01bc4a6c5ab50ac80f9a8e5d5c5db442f45 (patch)
tree8434910cae60074aa51113f9b99d3e9635ea39e0 /src/db/schemas/user.js
parentAdd register with validation (diff)
downloadnodejs-final-assignment-0ca7c01bc4a6c5ab50ac80f9a8e5d5c5db442f45.tar.xz
Register works, part of login and auth middleware
Diffstat (limited to 'src/db/schemas/user.js')
-rw-r--r--src/db/schemas/user.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/db/schemas/user.js b/src/db/schemas/user.js

index 9d08680..f490966 100644 --- a/src/db/schemas/user.js +++ b/src/db/schemas/user.js
@@ -1,6 +1,24 @@ import { model, Schema } from 'mongoose'; import { hash, compare } from 'bcrypt'; +export const deviceSchema = new Schema({ + name: { + type: String, + required: true, + trim: true + }, + createdAt: { + type: Date, + default: Date.now, + immutable: true + }, + lastSeen: { + type: Date, + default: Date.now, + required: true + } +}); + /** * User schema for MongoDB. * @type {module:mongoose.Schema} @@ -31,6 +49,10 @@ export const userSchema = new Schema({ type: Date, default: Date.now, immutable: true + }, + devices: { + type: [deviceSchema], + default: [] } });