can we write mongodb crud queries and aggregate query together?


In MongoDB can we execute below written query?


else is there any other way we can execute CRUD and aggregate query together.


Short answer - No you can't do this : .find(userName:"abc").aggregate([])

aggregation-pipeline is heavily used for reads which is mostly similar to .find() but capable of executing complex queries with help of it's multiple stages & many aggregation-operators. there are only two stages in aggregation $out & $merge that can perform writes to database - these stages are not that much used compared to other stages & needs to be used only when needed & as they need to be last stages in aggregation pipeline, then all the previous stages are to be tested very well. So when it comes to CRUD eliminating CUD you'll benefit over R - Reads.

Same .find(userName:"abc") can be written as :

.aggregate( [ { $match : { userName:"abc"} } ] ) // Using `$match` stage



  • Android-Change Edittext after each change
  • Translation after rotation
  • Can I host (self host) a WCF Service in a Windows Service and expose it via http?
  • Symfony2 Doctrine Unrecognized field:
  • Take picture automatically with no user interaction [closed]
  • Problem with time() function in embedded application with C
  • when i am trying to save the data to mysql, an exception is being thrown( java.sql.SQLException)
  • HighCharts Sankey Diagram in R
  • torchLevel KVO - iOS
  • Updating a 'master' JSON object by adding data to a subobject
  • lmerTest::anova not showing p-values
  • Password_verify in PHP
  • HUAWEI kill a background app when the phone is locked
  • AlertDialog before loading url in webview
  • Django: How to get the truncated portion of “truncatewords”
  • Basic search in wordpress
  • Does Tomcat cache compiled JSP pages in memory if scratchdir is read-only?
  • Youtube API Actionscript 3 and Thumbnails
  • JSON data - Group by days of the week(Sun,Mon,Tue, Wed,Thu,Fri,Sat) using Javascript/Jquery
  • touch events not working in android phonegap webview (or even built-in browser)
  • python: Using ncurses when underlying library logs to stdout
  • How to use OPENXML to load XML data into existing SQL Table?
  • How to filter out rows from spark dataframe containing unreadable characters
  • Python C binding error
  • List using with references, changes behavior when used as a member
  • Was there ever a proposal to include the URL fragment into the HTTP request?
  • $this->a->b->c->d calling methods from a superclass in php
  • dmtracedump doesn't work, HELP!
  • Find all parks for a given zipcode with google maps
  • First dynamically-added TinyMCE editor displays, others do not
  • Request Access Token in Postman for Azure Function App protected by Azure AD B2C
  • Ajax call on Multiple selection in Select box
  • Possible to set default CloudKit container not based on application name?
  • Typeahead.js does give me suggestions but doesn't select them
  • 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs
  • how to get the location(lat/lng) on google maps v3 from the location(x,y)
  • Send array to next viewcontroller iOs xcode [duplicate]
  • How to use FirstOrDefault inside Include
  • Firebase: How to read from external DB?
  • ReferenceError: TextEncoder is not defined