backend integration

This commit is contained in:
Moon Patel
2023-06-27 15:44:29 +05:30
parent 8edd05e020
commit b3fd3ade5c
11 changed files with 1504 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
const { Schema, default: mongoose } = require("mongoose");
const { String, ObjectId } = Schema.Types;
const userSchema = new Schema(
{
username: {
type: String,
unique: true,
required: true,
},
email: {
type: String,
unique: true,
required: true,
},
password_hash: {
type: String,
required: true,
},
fname: String,
lname: String,
location: String,
country: String,
friends: {
type: [ObjectId],
ref: "User",
},
},
{
virtuals: {
fullName: {
get() {
return this.fname + " " + this.lname;
},
},
},
}
);
module.exports.User = mongoose.model("User", userSchema);