I’ve created an update function using Mongoose. However whenever I update the data using findOneAndUpdate. It updates only the fields entered and making it so that the others are now null or empty. I would like it so that when the user is updating and they dont update a filed it should remain as what it was before instead of
Tag: mongodb
Mongodb Compare two fields with ratio
Rows whose field is twice that of the other field explain with example : I want row that spend is equal or bigger twice price (spent >= 2*price) result : {id : 1 , price : 40 , spent : 90} ==> (spent >= 2price) [90>80]* {id : 1 , price : 80 , spent : 200} ==> (spent >=
MongoDB & Prisma: unilateral M-to-N relation
Is there a way to make an unilateral m-to-n relation or must both collections have each other’s ids? I’m trying to do something like this: But prisma is making me add another field to Country to store the users ids… Like this: I don’t need that data and it’s not logically needed. Is there any way to bypass that? Any
meteor How to use upsert | Exception while simulating the effect of invoking ” TypeError: Cannot read properties of undefined (reading ‘_id’) react.js
I’m having trouble with upsert with meteor.js. I could update questions finely with the below codes but I won’t be able to insert new data. file in client side file in server side (collection file) Got error saying… Exception while simulating the effect of invoking ‘modifyQuestion’ TypeError: Cannot read properties of undefined (reading ‘_id’) I thought when {_id: questionId._id} got
MongoDB match expression query not working
MongoDb query match expression not working. I have a posts collection and want to return only those posts which match the user Id of the user who created it but my query does not seem to be working. Sample Dataset MongoDb Query:- Query Output:- The query does not work output contains posts created by all users it is not filtering.
How can I list all the records to see if they are duplicated?
I have a problem that I cannot resolve. I have a table in MongoDB, and this is structure: I need to list all names from the table (shopData.name) and then check if the typed name exists in the database. I tried to do something like the one below, but it doesn’t work. Could someone take a look at this and
Can’t get single item to delete by id from mongoDB in nextjs app
I’m making a todo app in nextjs to practice, and I am having a hard time getting single todos to delete from the database using the deleteOne function. Here is the call from the front end: and here is the handling of the DELETE method: and the deleteTodo helper function it calls: I can get it to delete the first
How to return sorted array from object from MongoDB document?
I want to return an array, which is a property inside my mongo model/document, and I want that array to be sorted. My MongoDB document looks like: And I’m trying to return: I have tried aggregation: Answer Mongo Playground reference Since $unwind returns the arrays as objects, we are using the $group to push the objects back into the items
Best method to keep track of a users progression through reading sections of text
Similar to zyBooks if you are familiar with it, I want to track the sections the user has read through and checked completed with a button. However, conceptually I am having trouble thinking of what to store in my mongo database, besides just an object or an array of objects that contains each section and bool values, to track their
why req.body.title shows ‘undefined’
I’m new to NODE JS and practicing with some POST forms from PUG to a NODE JS server. I have a simple form to update a photo title and description posted onto mongodb. When I submit the form from the web browser the submission input comes back to the server as ‘undefined’. These two processes in POST log ‘undefined’: (see