Skip to main content
  1. About
  2. Stack Internal
The 2026 Annual Developer Survey is live— take the Survey today!
Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 3
0 answers
84 views

I am building a multi-tenant application, and I am using a global plugin instead of adding a plugin to each model one by one. This plugin will handle adding organizationId during filters, saving, and ...
Score of 0
1 answer
253 views

Based on the answer in How to register same mongoose hook for multiple methods? const hooks = [ 'find', 'findOne', 'update' ]; UserSchema.pre( hooks, function( next ) { // stuff } The code above ...
  • reputation score 2947
Score of 1
0 answers
82 views

I am implement cascade like for mongodb using pre remove middleware of mongoose follow : Cascade style delete in Mongoose But I when having errors it not rollback deleted data. So how can we start ...
  • reputation score 886
Score of 2
2 answers
851 views

When I execute this model,I get error. Please solve this question. This problem brought me headache. Opposed to using 'Content here, content here', making it look like readable English, many desktop ...
  • reputation score 21
Score of 1
0 answers
1337 views

I am trying to use a mongoose middleware to recursively delete references to this object in another objects array (delete task references in taskList with the id from task) The problematic function: ...
  • reputation score 1427
Score of 1
1 answer
2151 views

I want to execute same script in the pre-hook with multiple methods like this: UserSchema.pre("findOne", function(next) { console.log("Common code"); }); & UserSchema.pre(&...
Score of 0
1 answer
690 views

userschema.pre('save',async function(next){ const user =this; if(user.isModified('password')){ user.password=await bcrypt(user.password,8) } next() }) i am first time ...
  • reputation score 13
Score of 2
0 answers
173 views

i am using "mongoose-extend-schema": "^1.0.0" with mongoose to add a base schema to all other schemas. here is my code: import mongoose from "mongoose"; interface ...
Score of 0
1 answer
269 views

I have a model, let's call it Client and i have another model called Accounts. They are from difference collections, a client can have many different accounts. I reference the accounts within the ...
  • reputation score 1779
Score of 0
1 answer
197 views

I'm trying to sort an internal array of document references in a document by the values in the referenced documents. I'd like to do this every time I run a query so if I can do this with a query sort(...
  • reputation score 496
Score of 3
1 answer
1896 views

Considering the code below, how can a transaction be implemented in order to ensure that someParentDocument doesn't get deleted and any operations performed inside the hooks are rolledback, when an ...
  • reputation score 1558
Score of 1
1 answer
1183 views

I'm adding a series of documents to the database. Each of these documents is validated in a pre-save hook. I want Mongoose to ignore saving that particular document that fails the validation without ...
  • reputation score 222
Score of 2
2 answers
1486 views

I have an app that uses MongoDB via mongoose. On the app there is a collection called Notifications. I would like to detect every time there is a change in that collection(including deleting a ...
  • reputation score 8044
Score of 0
0 answers
85 views

i wan't to know what's the difference between calling the middleware with next and without next example without next All middleware run perfectly fine without next also tourSchema.pre('save', ...
  • reputation score 323
Score of 1
2 answers
2268 views

i am first time using pre save middleware and getting a bit confusion in it. It runs perfectly fine and also my save method is getting executed eventhough i am not calling the next() case 1 ...
  • reputation score 323

15 30 50 per page
1
2

AltStyle によって変換されたページ (->オリジナル) /