Code-the-Dream-School / ffprac-team4-back

Back End Repo for Ferret/Flamingo Practicum Team 4
https://ffprac-team4-back.vercel.app
0 stars 3 forks source link

Create database schemas for users, toys, messages, and wish lists. #14

Open AmirhosseinOlyaei opened 7 months ago

morarodgers commented 7 months ago

const mongoose = require('mongoose')

const ToySchema = new mongoose.Schema({ id: { "type": "ObjectId", "required": true }, userId: { "type": "ObjectId", "required": true }, description: { "type": "String", "required": true }, pictures: { "type": ["String"], "required": true }, ageRange: { "type": "String", "required": true }, methodOfPickup: { "type": "String", "required": true }, status: { "type": "String", "required": true }, ratings: [ { "stars": { "type": "Number", "required": true }, "review": { "type": "String", "required": true } } ] } );

morarodgers commented 7 months ago

const mongoose = require('mongoose')

const UserSchema = new mongoose.Schema({ id: { "type": "ObjectId", "required": true }, username: { "type": "String", "required": true }, email: { "type": "String", "required": true }, phone: { "type": "String", "required": true }, location: { type: { type: String }, coordinates: [Number] }, preferredExchangeMethod: { "type": "String", "required": true }, ratings: [ { stars: {"type": "Number", "required": true }, review: { "type": "String", "required": true } } ] } );

module.exports = mongoose.model('Toy',UserSchema)

morarodgers commented 7 months ago

/ User Profile Management Location Email Phone number Preferred way of exchange ( pickup/drop off) rating (star system + review ) /

/* models

// schema design to store information about users like name, geographic location const userSchema = new mongoose.Schema({ name: { first: String, last: String }, // GeoJSON is a format for storing geographic points and polygons. location: { type: { type: String, enum: ['Point'], required: true }, coordinates: { type: [Number], required: true } }, exchangeMethod: { type: String, enum: ['pickup', 'drop-off'], required: true } })

//schema representing rating (star system + review ) const reviewSchema = mongoose.Schema( {

    rating: {
        type: Number,
        required: true
    },
    comment: {
        type: String,
        required: true
    },
    addedBy: {
        type: mongoose.Schema.Types.ObjectId,
        required: true,
        ref: 'User'
    }
}

)

/ Ability for users to post toys that they want to exchange. description picture(s) of toys rating (star system + review ) age / range method of pickup each post has a status /stage that the user can manage user should have the ability to edit a post /

const toySchema = mongoose.Schema({ user: { type: mongoose.Schema.Types.ObjectId, required: true, ref: "User", }, toyName: { type: String, required: true, }, toyImage: { type: String, required: true, }, toyDescription: { type: String, required: true, }, exchangeMethod: { type: String, enum: ["pickup", "drop-off"], required: true, }, });

avspeed commented 7 months ago

@morarodgers @betielamanuel Please find the updated information regarding what we need to capture in the application along with the routes that will need to be created. If you have questions please ask thank you :

User: email first_name last_name profile_picture nickname zipcode created_by_id create_date modified_date modified_by_id Route: CREATE UPDATE GET: ability to pass filter

Toy Listing: user_id (user that created) given_to_user_id title description condition delivery_method pictures category zip_code status created_by_id create date modified_date modified_by_id Route: CREATE UPDATE GET: ability to pass filter DELETE

Star System: user_id_given_by user_id_given_to number_of_stars created_date Route: CREATE GET

Request: toy_listing_id user_id_of_the_user_requested date_requested Route: CREATE GET: request from specific toy listing id

Message: user_id_from user_id_to toy_listing_id content sent_date Route: CREATE GET

Category: (toy, games, …) category_id name enabled sort_order Route: GET

Delivery Method: (…) delivery_method_id name enabled sort_order Route: GET

Status: (…) status_id name enabled sort_order Route: GET

Condition: (…) condition_id name enabled sort_order Route: GET

Favorites: toy_listing_id user_id time_stamp Route: CREATE GET DELETE

Front End Default route: listing listingdetail login userprofile messages createlisting

betielamanuel commented 7 months ago

https://github.com/Code-the-Dream-School/ffprac-team4-back/pull/15 please follow this link to see the changes made