I'm encountering an issue with my code. It works fine for uploading images, but when I try to upload videos or files larger than 16mb, it fails. I am a beginner and seeking help on what to do next. const Freecoursevideo = require("../models/freecour ...
const accountSchema = new mongoose.Schema({ username: { type: String, required: true, unique: true }, password: { type: String, ...
Whenever I attempt to import this code, the page throws an error: Uncaught TypeError: Cannot read properties of undefined (reading 'split') import { User } from '@/assets/schemas' export default { name: 'HomeView', mount ...
I am currently working on setting up a login route URL for each company admin's profile. In the past, I implemented a similar approach with a single schema. Now, however, I am facing challenges as I try to do the same within a nested structure. My go ...
I need to establish relationships between my schemas in the "Movie" entity so that I can access information from other entities like: Category Actor Director Studio Right now, I am testing with categories. This is the code I have written: controllers/m ...
Seeking guidance on fetching and summing up the values of the "caseCount" objects within a schema. Can anyone provide me with assistance in accomplishing this task? Feel free to ask for further details if needed. Thank you! This is the Schema: const Profi ...
I have a document containing an array of questions. Each time I click the submit button, I would like a function to retrieve the next question from the array. Essentially, it's a quiz app where questions are stored in a database and all questions are ...
As a newcomer in the field of web development, I am attempting to create a basic editable image gallery. In order to achieve this, I have established a Collections schema alongside a Paintings schema: var collectionSchema = new mongoose.Schema({ name: ...
Currently, I am utilizing Aws-S3 to store files for a project. The main obstacle I am facing involves retrieving the object URL and incorporating it into the Mongoose data model as a string when calling the POST method. Below is the code snippet for Next. ...
Situation: Using Mongoose v4.7.6 Working with MongoDB v3.2.11 Currently facing issues regarding database errors in my software. Encountering a problem where mongoose requests hang when the database is disconnected and only resume once reconnected. Th ...
Struggling to store an array of objects in mongodb using mongoose and node, I am facing challenges with simple validation. I have defined a Schema and a custom validation function as follows: const mongoose = require("mongoose"); const fieldsSch ...
I'm currently in the process of developing a REST API using node, express, and MongoDB for a web application that has three main sections on the frontend: Quotes Stories News When a user clicks on Quotes, they should only see quotes; the same goes for S ...
I have created a list of objects called Comments Objects in which comments are stored, and whenever someone replies to a comment, it gets stored in the children section. { "_id": "5dbc479babc1c22683b73cf3", "comment": "wow .. this is awesome", ...
I need help troubleshooting a mongoose error that is being thrown. throw new mongoose.Error.MissingSchemaError(name); ^ MissingSchemaError: Schema hasn't been registered for model "Appointment". Use mongoose.model(name, schema) I have double-checke ...
Currently I am working with two models, namely Comment and Report. const mongoose = require('mongoose'); const CommentSchema = new mongoose.Schema( { content: { type: String, trim: true, maxLength: 2048, ...
Currently exploring the creation of a user schema in TypeScript. I've observed that many people use an interface which functions well until I introduce a message involving username.unique or required property. No error code present: import {model, mo ...
I'm looking to develop a feature where every time a user creates a new thread post, it will be linked to the User model by adding the newly created thread's ID to the threads array of the user. However, I'm running into an issue when trying to create a thr ...
Currently, I find myself in a scenario where I need to simultaneously push and pull data. I've designed Schemas for categories and posts, where each post can be associated with multiple categories. This is achieved by using Object Referencing method ...
Is there a way to successfully implement the following structure? [{ "title": "pranam", "year": "2016", "rating": 9, "actors": [ { "name": "Amir", "birthday": "16 Aug 1982", "country": "Banglades ...
Before grouping the data in my query, I want to get the total count of all documents. This is important because once I have the count, I can easily calculate the percentage for each student. I tried using $count but it interfered with my ability to group t ...
I have a book schema using Mongoose Schema const bookSchema = new mongoose.Schema({ bookName: { type: String, minlength: 1, maxlength: 255, required: true, trim: true }, price: { type: Number, ...
As someone who is fairly new to these technologies, I'm unsure if I am doing this correctly. I am attempting to display the name of the category in the table instead of the id (which is from the ObjectId schema field) for all the Category documents r ...
How can I refactor this code to move the entire DB query logic into a separate file and only call the function in this current file? passport.use( new GoogleStrategy({ clientID: googleId, clientSecret: clientSecret, callbackURL: ...
I've been struggling to test the controller logic for a user validation module, but I keep encountering an error that says "res is not defined" even after trying to define it. How can I properly define it so that it runs through the condition statemen ...
I am encountering an issue with sending data from a basic HTML form to MongoDB using Express. When I try to post it, I am getting null as the result. The Schema I used is: commentname: String. Below is the snippet of the HTML code: <form id="form ...
I am currently dealing with 2 mongoose Schemas structured like this: var RecipeSchema = new Schema({ type: String, version: String, data: [{type: Schema.ObjectId, ref: 'Data'}] }); var Recipe = mongoose.model("Recipe", RecipeSchema ...
I am facing a particular issue. I have comments in my database that can be soft-deleted using a flag is_deleted. When this flag is set to true, it means the comment has been deleted. The comments are not stored as an independent model; instead, they are n ...
I have been struggling to create a new collection and push it into a specific user's collections array. Despite researching various stackoverflow posts, I am unable to achieve this using either User.update() or User.findOneAndUpdate(). I can confirm t ...
Looking to create a JSON model or schema for storing form input data on a local JSON file, I have experience with MongoDB but want to keep it simple in this project by using a basic JSON file. Is there a way to structure the data similar to a Mongoose sche ...
I created a like button in React that saves my choices, but it seems to be not saving the choices of other users. Additionally, it doesn't appear to restrict only authenticated users from marking likes. Can someone please help me identify what I'm doing wr ...
Despite my efforts, I couldn't find the information I was looking for on Google. Currently, I am using Node.js, Express, and Mongoose to work on initializing a new Object. var User = require("../modules/user/model/user"); var user = new User(); cons ...
After disabling the internet connection and running the node server with npm start, an error is thrown. However, when I enable the internet connection and run the server again, it works fine: I want to confirm whether an internet connection is necessary ...
I have a schema structure as follows: const propertiesSchema = new Schema({ name: { type: String, required: true }, shortDescription: String, totalArea: String, address: { type: mongoose.Schema.Types.ObjectId, ...
I am facing an issue with my model as it keeps having errors after the first POST request. The project involves creating a scheduling application that spans over X number of days, each day having rooms and time slots for those rooms. The problem I am enco ...
Hello, I am new to mongodb and looking for some guidance on the best practices to follow. Currently, I am working on setting up a simple blog using mongoose schemas like this: Blog Schema: const Blog = new Schema({ title : String, description : S ...
As I embark on my journey of creating my first nodejs app, I encountered an error when attempting to transfer a portion of my code to an external JavaScript file. The specific piece of code I am trying to move is the mongodb schema declaration: var mongoo ...
Hi there, I'm currently exploring MongoDB and Mongoose. My goal is to prevent users of my API from storing duplicate contact names in the Mongo database, but unfortunately it's not working as expected. This is how I have set up the validation: both name a ...
I am facing an issue with rendering HTML content retrieved from a MongoDB database using Pug. When I try to render the HTML, it duplicates the output unexpectedly... The getArticle function in viewController.js is a middleware used by routes like '/a ...
Currently, I am developing an API using Mongo, Express, and Node. At the moment, I have two collections: users userlist My goal is to implement a change password functionality for users which allows updating the password of the logged-in user. Below is ...
Struggling with Establishing Relations in MongoDB Collection for REST API Data Retrieval As a newcomer to NodeJs and MongoDB, my goal is to build a REST API that retrieves data on categories and products. Specifically, I want to establish a connection bet ...
Within this scenario, I have two distinct models: Protocol and Comment. Each model incorporates a middleware ('pre' or 'remove') that triggers the other model. The issue arises when attempting to call the Comment middleware in Comment.j ...
I have a scenario where I create a schema in one file // Vendor.ts export { ShortVendorSchema }; const ShortVendorSchema = new Schema<TShortVendor>({ defaultVendor: Boolean, companyName: String, vendorId: { type: Schema.Types.ObjectId, ...
Below is the code snippet: const mongoose = require('mongoose'); const Schema = mongoose.Schema; const userSchema = new Schema({ name: { type: String, required: true }, email: { type: String, required: true ...
I am trying to establish a connection between Users, Posts, and Comments by linking them together. However, I keep encountering an unexpected error: ID cannot represent value: <Buffer 5e 9b f1 3e e9 49 61 38 fc 1a 6f 59> Here is my code. If you ca ...
I have a situation where I need to update the document in MongoDB for three different chatrooms only if the user's id matches with the member's user_id. However, I am facing an issue where the token is being updated across all devices of the memb ...
const adminsSchema = new mongoose.Schema({ username: String, password: String, }); const secretKey = "CrackThis1"; adminsSchema.plugin(encrypt, { secret: secretKey, encryptedFields: ["password"] }); const AdminUser = ne ...
Just entering the world of mongoose and looking to validate an array with specific predefined values like enum. Check out my schema below: const movieSchema = new mongoose.Schema({ language:{ type:[String], enum : ['Hindi','English','Gujarati',' ...