Skip to main content

Questions tagged [mongoose]

Mongoose is a MongoDB object modeling tool, or ODM (Object Document Mapper), written in JavaScript and designed to work in an asynchronous environment.

0 votes
0 answers
3 views

OverwriteModelError: Cannot overwrite AddOnsDatabase model once compiled. [Typescript]

Im using nextjs i keep getting the error OverwriteModelError: Cannot overwrite AddOnsDatabase model once compiled. to fix this error i am using the OR operator to check if the model already exists ...
Rudransh Shrivastava's user avatar
-3 votes
0 answers
10 views

How to set relation between post and author schema in mongodb , I have to save post created by particular author so that I can fetch easily later

const mongoose = require("mongoose"); const Schema = mongoose.Schema; const postSchema = new mongoose.Schema({ title: { type: String, required: true, }, ...
Ashish Kumar's user avatar
-1 votes
0 answers
14 views

Check if string contains any item of array in mongoose find query [duplicate]

I'm trying to find entries where the title field contains any item of an array. Here is the relevant part of my schema: const blogSchema = mongoose.Schema({ title: { type: String, required: ...
Ali Hosam's user avatar
0 votes
0 answers
37 views

I can't import my User model on my new service files, it says undefined

I have an express.js application. It contains several models and the User model is one of them. When I tried to import the User model in my new service files, I got 'TypeError: Cannot read properties ...
kuraidesu's user avatar
0 votes
0 answers
22 views

issue with connecting mongodb through mongoosejs

so I'm using this type of code to connect to mongodb - github link to code const mongoose = require('mongoose') cosnt s = "my connection url" mongoose.Promise = global.Promise ...
Xx-Mohit-xX's user avatar
0 votes
1 answer
30 views

Mongodb aggregate multiple collections super slow

New to Mongo so bare with me, but cannot figure out best (fast) solution. I have three different collections: Shipments, Tracking, Messages I'm trying to join two simple fields from the Tracking and ...
Stephen Clark's user avatar
0 votes
0 answers
16 views

how to re-validate the only card that a change has been made to it without reloading/revalidate the whole page

I have this component that renders <CardsList/> which is a <ul> and inside it I'm rendering many of <li> called <BeanCard/>: import { getBeans } from "@/API/apiBeans";...
Marya's user avatar
  • 119
0 votes
0 answers
24 views

Switch the Database of the default mongoose connection

In trying to limit the number of connections in my web application I switched from using mongoose.createConnection() to mongoose.connect() Which works perfectly if your only ever using one database. ...
TheReezen's user avatar
-1 votes
1 answer
47 views

Store object array of product size and colors in mongo DB

I need to store object array of product size and colors. Is it possible in mongo DB.(Because in ms sql it is not allowed).If so how the schema should be?.Sample object structure is shown below { color ...
yasith's user avatar
  • 25
-1 votes
1 answer
36 views

How to remove data from mongo dab using $pull operator

i am new in the field mern stack and i want your help to remove to remove comment from User data which is equal to Post data comment Post Data: { _id: new ObjectId('66985b5774dd3a87fd1be9d4'), ...
GAMING WARRIOR's user avatar
0 votes
0 answers
28 views

Scaling mongodb for a social media feed

Are there limitations to how much mongodb can scale when it comes to querying millions of documents. I'm designing a social site, similar to twitter where users will have a chronological feed of posts....
John Scipion's user avatar
0 votes
2 answers
23 views

How do I use the find() method to query a mongoose schema with an enum field (can hold multiple values (array)) that includes a particular value?

I have this schema: const User = new Schema({ firstName: { type: String, required: true }, lastName: { type: String, required: true }, mobile: { ...
Textbook's user avatar
  • 119
0 votes
1 answer
53 views

Query MongoDB documents for a particular date range [duplicate]

I am trying to query documents based on particular date range. So I need all the documents where the createdDate is less than equal to current date and greater than equal to currentDate - 2. I am ...
Nikhil Bansal's user avatar
-1 votes
0 answers
56 views

Mongoose doesn't create new document [closed]

I'm trying to create a new document. This is the function in the API router (using express.js) mongoose .connect('mongodb://localhost:27017/name') .then(() => { console.log('Connected to DB ...
idobarabi's user avatar
0 votes
1 answer
37 views

Is there a way to change a field from an array to a single element in a mongodb query

I am trying to query my DB on a collection but I have some field that I would like to change from an array of objects to a single object that have been picked up randomly from the array. is this ...
Magnus's user avatar
  • 3

15 30 50 per page
1
2 3 4 5
3127