Skip to content

Commit

Permalink
feat: user and favorite models
Browse files Browse the repository at this point in the history
  • Loading branch information
felixtanhm committed May 8, 2024
1 parent 8d3238d commit 9f2049c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const mongoose = require("mongoose");

const Schema = mongoose.Schema;

const FavoriteSchema = new Schema({
user: { type: Schema.Types.ObjectId, required: true },
favorites: {
type: [Schema.Types.ObjectId],
ref: "Pokemon",
default: () => {
return null;
},
},
created_at: { type: Date, default: Date.now() },
last_modified: { type: Date, default: Date.now() },
});

// Export model
module.exports = mongoose.model("Favorites", FavoriteSchema);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require("mongoose");

const Schema = mongoose.Schema;

const UserSchema = new Schema({
name: { type: String, required: true },
email: { type: String, required: true },
created_at: { type: Date, default: Date.now() },
last_modified: { type: Date, default: Date.now() },
});

// Export model
module.exports = mongoose.model("Users", UserSchema);

0 comments on commit 9f2049c

Please sign in to comment.