summary refs log tree commit diff
path: root/src/db/schemas/spendHistory.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/schemas/spendHistory.js')
-rw-r--r--src/db/schemas/spendHistory.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/db/schemas/spendHistory.js b/src/db/schemas/spendHistory.js
new file mode 100644

index 0000000..b12bcc3 --- /dev/null +++ b/src/db/schemas/spendHistory.js
@@ -0,0 +1,29 @@ +import { model, Schema } from 'mongoose'; +import { hash, compare } from 'bcrypt'; +import {ref} from "joi"; + +/** + * User schema for MongoDB. + * @type {module:mongoose.Schema} + */ +export const spendHistorySchema = new Schema({ + spentBy: { + type: ObjectId, + ref: "users" + } + createdAt: { + type: Date, + default: Date.now, + immutable: true + } +}); + +export const UserType = Object.freeze({ + USER: 'user', + MONITOR: 'monitor', + ADMIN: 'admin' +}); + +export const DbUser = model('user', userSchema); + +console.log('[MONGODB] User schema initialized successfully!');