Skip to content
Advertisement

Tag: mongodb

How can I save checkbox state to my database?

I’m trying to create a Todo-list app using (nodejs,ejs…) so for every todo I create a checkbox. If someone finishes his job and uses the button bin recycle to delete it, I save that using MongoDB but I’ve a problem when checking. When I reload the page this checked box disappears. In other words, my question is: How to save

mongoose.connect() is undefined

I’m trying to connect to my MongoDB using Mongoose and it gives me the following error. I get this Error Answer You should change 2 things: Change { mongoose } with mongoose Remove useNewUrlParser option. New version of Mongoose does not accept it as option and it will throw an error.

Destructuring a mongoose document

Using mongoose in my project, I ran into a problem. I want to find all documents that have such a key and value pair role: USER. I can get a list of documents, but I cannot get the values of specific fields from it, no matter how I try. Here is my code: The request definitely gets the document, because

React: Converting mongoDB date to human readable date

A document stored in MongoDB has a “createdAt” property, which contains a timestamp. Here we have an example of the timestamp: Considering this date is today, how can I reproduce the following behavior?: Display this date as “Today at 12:24 PM” Tomorrow, display this date as “Yesterday at 12:24 PM” From the day after tomorrow and beyond, display it as

mongodb collection uuid how to update?

How to create collection in mongodb with specific uuid or update the uuid ? Adding details: When I create a collection mongodb generate automatically uuid and if this is replicaSet the uuid is replicated to all SECONDARY members via the oplog: But I would like to know if there is an option this UUID to be created with command or

In “mongosh”, how do I delete all databases without deleting the typical “admin”, “config”, or “local” databases?

What am I trying to do? I wrote a script called deleteDatabases.js and it’s supposed to delete all databases (besides “admin”, “config”, or “local”) when inside mongosh. I do not have access to mongo, only mongosh. What is the code that currently tries to do that? deleteDatabases.js Inside mongosh: Before what I did to successfully delete these databases was: What

Advertisement