Spaces:
Runtime error
Runtime error
Download models/userModel.js from Beshoy-mounir/firstapp: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/spaces/Beshoy-mounir/firstapp/resolve/main/models/userModel.js
- Command line
-
hf download hf://spaces/Beshoy-mounir/firstapp/models/userModel.js
-
curl -L -o userModel.js https://huggingface.co/spaces/Beshoy-mounir/firstapp/resolve/main/models/userModel.js
1.56 kB
| const mongoose = require('mongoose'); | |
| // ------------------ | |
| // Cart Item Schema | |
| // ------------------ | |
| const cartItemSchema = new mongoose.Schema( | |
| { | |
| product: { | |
| type: mongoose.Schema.ObjectId, | |
| ref: 'Product', | |
| required: true, | |
| }, | |
| quantity: { | |
| type: Number, | |
| default: 1, | |
| min: 1, | |
| }, | |
| size: String, | |
| color: String, | |
| }, | |
| { _id: false }, | |
| ); | |
| // ------------------ | |
| // Address Schema | |
| // ------------------ | |
| const addressSchema = new mongoose.Schema( | |
| { | |
| city: String, | |
| street: String, | |
| building: String, | |
| phone: String, | |
| }, | |
| { _id: false }, | |
| ); | |
| // ------------------ | |
| // User Schema | |
| // ------------------ | |
| const userSchema = new mongoose.Schema( | |
| { | |
| name: { | |
| type: String, | |
| required: true, | |
| }, | |
| email: { | |
| type: String, | |
| required: true, | |
| unique: true, | |
| lowercase: true, | |
| }, | |
| phoneNumber: { type: String, require: true }, | |
| password: { | |
| type: String, | |
| required: true, | |
| }, | |
| membership: { | |
| type: String, | |
| enum: ['basic', 'premium', 'vip'], | |
| default: 'basic', | |
| }, | |
| cart: { | |
| items: [cartItemSchema], | |
| }, | |
| pastOrders: [ | |
| { | |
| type: mongoose.Schema.ObjectId, | |
| ref: 'Order', | |
| }, | |
| ], | |
| addresses: [addressSchema], | |
| shippingAddress: addressSchema, | |
| theme: { | |
| type: String, | |
| default: 'light', | |
| }, | |
| notifications: { | |
| type: Boolean, | |
| default: true, | |
| }, | |
| }, | |
| { timestamps: true }, | |
| ); | |
| module.exports = mongoose.model('User', userSchema); | |