We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
import dotenv from "dotenv"; import mongoose, { model, Schema } from "mongoose";
dotenv.config();
if (!process.env.MONGODB_URI) { throw new Error("MONGODB_URI is not defined in the .env file."); }
// Connect to MongoDB mongoose .connect(process.env.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true, } as mongoose.ConnectOptions) .then(() => { console.log("Successfully connected to MongoDB."); }) .catch((error) => { console.error("Error connecting to MongoDB:", error); process.exit(1); });
//User schema const UserSchema = new Schema({ username: { type: String, unique: true }, password: String, });
export const UserModel = model("User", UserSchema);
// Content schema const ContentSchema = new Schema({ title: String, link: String, tags: [{ type: mongoose.Types.ObjectId, ref: "Tag" }], type: String, userId: { type: mongoose.Types.ObjectId, ref: "User", required: true }, });
export const ContentModel = model("Content", ContentSchema);
// Link schema const LinkSchema = new Schema({ hash: String, userId: { type: mongoose.Types.ObjectId, ref: "User", required: true, unique: true }, });
export const LinkModel = model("Links", LinkSchema);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import dotenv from "dotenv";
import mongoose, { model, Schema } from "mongoose";
dotenv.config();
if (!process.env.MONGODB_URI) {
throw new Error("MONGODB_URI is not defined in the .env file.");
}
// Connect to MongoDB
mongoose
.connect(process.env.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
} as mongoose.ConnectOptions)
.then(() => {
console.log("Successfully connected to MongoDB.");
})
.catch((error) => {
console.error("Error connecting to MongoDB:", error);
process.exit(1);
});
//User schema
const UserSchema = new Schema({
username: { type: String, unique: true },
password: String,
});
export const UserModel = model("User", UserSchema);
// Content schema
const ContentSchema = new Schema({
title: String,
link: String,
tags: [{ type: mongoose.Types.ObjectId, ref: "Tag" }],
type: String,
userId: { type: mongoose.Types.ObjectId, ref: "User", required: true },
});
export const ContentModel = model("Content", ContentSchema);
// Link schema
const LinkSchema = new Schema({
hash: String,
userId: { type: mongoose.Types.ObjectId, ref: "User", required: true, unique: true },
});
export const LinkModel = model("Links", LinkSchema);
The text was updated successfully, but these errors were encountered: