MongoDB - Filtering the content of an internal Array in a resultset

后端 未结 5 571
再見小時候
再見小時候 2021-02-01 08:19

I\'m new using MongoDB, and I don\'t know how to solve the next problem:

I have a collection of documents like this:

{
 \"URL\": \"www.stackoverflow.com\         


        
5条回答
  •  悲哀的现实
    2021-02-01 09:07

    Generally speaking any find() operation on MongoDB returns all the documents that match the query and all documents are retrieved in their entirety. If you only want a specific section of a document then you have to do that processing on the client side.

    This is a fundamental difference between document databases and SQL databases. Typically in a document database a query returns all documents that match it while in an SQL database you can choose to return only portions of the table. Unless of course like you say you do a MapReduce but that kinda seems like overkill for your use case.

    Not to discourage you from using MongoDB but whatever project you work on consider whether NoSQL databases actually fit the bill (do they fill a requirement that SQL cannot) or whether you'd still be better going with a traditional SQL database.

提交回复
热议问题