express-message-board/models/user.js
ak f36b48f4ce progress update
image uploading works
hosted at deta space
2023-09-20 18:00:32 -07:00

18 lines
534 B
JavaScript

const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const UserSchema = new Schema({
username: { type: String, required: true },
password: { type: String, required: true },
_id: { type: mongoose.ObjectId, required: true },
avatar: { type: Buffer, required: true },
});
// Virtual for user URL
UserSchema.virtual("url").get(function () {
// We don't use an arrow function as we'll need the this object
return `/user/${this._id}`;
});
// Export model
module.exports = mongoose.model("User", UserSchema);