Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AmirhosseinOlyaei opened this issue Mar 9, 2024 · 5 comments
Assignees

Comments

@AmirhosseinOlyaei
Copy link
Collaborator

No description provided.

@morarodgers
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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

/*
models

  • userSchema.js
  • reviewSchema.js
  • exchangeMethodSchema.js
  • toySchema.js
    */

// 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
Copy link

avspeed commented Mar 18, 2024

@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
Copy link
Collaborator

betielamanuel commented Mar 19, 2024

#15
please follow this link to see the changes made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants