Category "mongoose"

mongodb set field value using if else during document update

Is there a way in mongodb to use if/else to set a field value during an update. i know that i can use find, to return documents, loop over them, and do if/else

Is there a less verbose way to write DynamoDB update params?

I am new to Dynamo and I created a simple todo API with Serverless Framework and TypeScript To update an Item I have to do this huge params const const params =

Mongoose - remove multiple documents in one function call

In documentation there's deleteMany() method Character.deleteMany({ name: /Stark/, age: { $gte: 18 } }, function (err) {}); I want to remove multiple documents

Using Mongoose and Typescript, what type should be used for a ref field of an interface?

I am using mongoose and Typescript, and I am wanting to know what type, or types, I should be using for a reference field, when creating an interface? Consider

Why can't I delete a mongoose model's object properties?

When a user registers with my API they are returned a user object. Before returning the object I remove the hashed password and salt properties. I have to use

nodejs multer retrieve stored images to the client side

I have created file storage in nodejs application to store images in uploads folder. which works fine but now I want to display those images I have read some ot

Fuzzy Searching with Mongodb?

I have managed to set up a search feature in my mongodb app. See the code below. This works very well however it only returns exact results. How would I change

How to Insert documents to multiple collection in a single query using nodejs

I am trying to insert documents into multiple collections by writing single query. Let consider that I have two collections person and address. I want insert d

How can I use partialFilterExpression on a mongoose model

I have created a mongoose model that has an email field. I want it to be unique if a value is provided by a user but I want it to be empty is a user has not pro

Mongoose: extending schemas

Currently I have two almost identical schemas: var userSchema = mongoose.Schema({ email: {type: String, unique: true, required: true, validate: emailValid