Mongodb Insert Nested Document

In MongoDB we can have document inside a document (embedded/nested document). This helps you in directly importing JSON data into MongoDB or transferring data from one Mongo collection to another. Resources:. When a MongoDB document contains a nested document (structure) it is faithfully encoded as a nested structure field. Nested classes/interfaces inherited from class com. The advantage to this approach is that all the related data can be retrieved with just one query. Remove a field from Documents. In this article we will demonstrate how quickly you can make a blog using ASP. An operation performed by the mapReduce command. Sample of document, and you want to remove the field "affLink". For an introduction to MongoDB and its set up read here. In the left-hand MongoDB Compass navigation pane, click: the database to which your target collection belongs. For example, if we want to replace the above example document representing a customer we can execute the following command in a MongoDB client: Identify a document by its internal ID and replace it entirely. You just need to use $set operator. With the embedded data model, your application can retrieve. Previously we have seen how to find documents, this article will help us understand how to update document in mongodb using java. You'd like to update one of those objects. " Atomic modifiers in MongoDB can only work against a single document. Question: Can you help me to create a nested family via the API? I have a column family and a shelf family stored in RFA files, and I would like to implement a command which creates a new family with column and the shelf, and load it into a project. Here is the read function which would read all the. jar to be present in the classpath. MongoDB allows programmers to save and query for data expressed in all of the basic PHP types, compound types (arrays, associative arrays, and objects), and a half-dozen classes provided by the MongoDB PHP driver (for regular expressions, dates, and other specialized applications). To insert a record, or document as it is called in MongoDB, into a collection, we use the insertOne() method. The above output shows that two documents have fetched from the collection "userdetails" but only the data of user_id, password and date_of_join have appeared for those documents who have the qualification "M. In this tutorial, I am listing 4 ways you can utilize to insert or add document(s) into a collection in MongoDB. [MongoDB]: For loop to generate documents with array, sub and nested documents August 13, 2016 · by dbversity · in MongoDB Find below sample for loop to generate a document with array, sub-document, nested-document. Internally, MongoDB represents JSON documents in binary-encoded format called BSON. Saving Nested Documents in MongoDb Using C# Driver In this screencast Mohammad Azam will demonstrate how to persist/save nested documents in MongoDb database using C# driver. Navigate to the collection you wish to insert the document: into: a. Pass an array of documents to the method. Filters helper methods to facilitate the creation of filter documents. MongoDB Pros and Cons 1. Note: If the query finds more than one record, only the first occurrence is updated. Here is another interesting question that came up on the creation of a nested family. insertOne(doc);. Document model preserves the view of a particular application Hierarchically nested objects; Potential redundancy; No need to "decompose" data for storage and "join" them back for retrieval; Retrieving data with different "view" is difficult; Basic MongoDB commands Basic CRUD operations: insert(), find(), update(), and remove(). Practically, you don't need to define a column and it's datatype unlike in RDBMS, while working with MongoDB. reactivestreams. update()" method and "db. The cool thing about MongoDB is that you need not to create collection before you insert document in it. So, it is quite possible to store documents of varying structures in a collection. The following example inserts three new documents into the inventory collection. From the database view, click the target collection name. This field has a number of special characteristics: -Value serves as primary key for collection. You can change your ad preferences anytime. Query a Document To query a document in MongoDB, input the find() command. We're the creators of MongoDB, the most popular database for modern apps, and MongoDB Atlas, the global cloud database on AWS, Azure, and GCP. Also, the same serialisation rules specify how a BSON document is mapped to a C# object. _id field is immutable which means you cannot change it. See » Specify arrayFilters for Array Update Operations in the MongoDB manual for more information. In MongoDB we can have document inside a document (embedded/nested document). In this example we use an empty query object, which selects all documents in a collection (but returns only the first document). python,mongodb,pymongo. In MongoDB, a document is a big JSON blob with no particular format or schema. A nested table is one table placed inside of another, where the larger table functions as a container for the smaller one. insertMany() New in version 3. Also, the same serialisation rules specify how a BSON document is mapped to a C# object. MongoDB was developed as a database that would scale gracefully across several machines over a network, often referred to as horizontal scalability. Insert only accepts a final document or an array of documents, and an optional object which contains additional options for the collection. Relationships can be modeled via Embedded and Referenced approache. This means that objects are stored as markup in documents. It allows to override the type identification of a value. "Update" is a builder. Collections and documents are akin to SQL tables and rows, respectively. Here is the read function which would read all the. find() find() method will display all the documents in a non-structured way. MONGODB This is a reference page for myself on what i learned on the MONGODB, through the mongodb Univeristy. Apache HBase is an open-source, distributed, versioned, non-relational database modeled after Google's Bigtable: A Distributed Storage System for Structured Data by Chang et al. Fetch all data except selective field from collection based on a criteria. It is an open-source, cross-platform, document-oriented database written in C++. Please refer for 10gen's article to get more solid understanding of the approach. How to insert Nested Documents using JSON String. In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. 1BestCsharp blog 7,717,803 views. 6 and make use of low level bulk commands on the protocol level. The cool thing about MongoDB is that you need not to create collection before you insert document in it. Reference to mongodb collection that handles hydration and de-hydration of documents into entities and vice-versa. PowerExchange for MongoDB provides an option to directly interact with JSON data when extracting from or loading data to MongoDB. Pass an array of documents to the method. Documents are a much more natural way to represent data. Unlike RDBMS where all records stored in a table must be confined to the table schema, documents of any structure can be stored in the same collection. Atomic modifiers in MongoDB can only work against a single document. Set the Multi Parameter to update all documents that match the query criteria. The below code example can be used to insert multiple documents at a time. An operation performed by the mapReduce command. A document in MongoDB is the same as a record in MySQL The first parameter of the insertOne() method is an object containing the name(s) and value(s) of each field in the document you want to insert. TIP The driver provides com. An embedded, or nested, MongoDB Document is a normal document that's nested inside another document within a MongoDB collection. DOC files• A document is essentially an associative array• Document == JSON object• Document == PHP Array• Document == Python Dictionary• Document == Ruby Hash• etc. This requires the library mongo-2. pymongoimport is a collection of python programs for importing CSV files into MongoDB. My name is John Jenson 3. In last tutorial, we learned about MongoDB insert with Mongo Shell and Java driver. Prisma adopts the idea of embedded types when modeling data for an underlying MongoDB. An array of documents. What I need to do is create a nested structure of documents all with a unique ID. INSERT INTO agent1 SELECT * FROM agents WHERE agent_code=ANY( SELECT agent_code FROM customer WHERE agent_code =ANY( SELECT agent_code FROM orders WHERE ord_amount>1000 GROUP BY ord_amount)); SQL insert using nested subqueries with any operator and group by and order by. The C# driver has the helper methods Push, which pushes a BsonDocument, or PushWrapped, which allows you to push an instance of the object used when instanciating the MongoCollection. Set the Multi Parameter to update all documents that match the query criteria. If document is found then Update operation. Since the Id member can be of any type, the driver requires the help of a matching IdGenerator to check whether the Id has a value assigned to it and to generate a new value if necessary. Relationships can be modeled via Embedded and Referenced approache. 1BestCsharp blog 7,717,803 views. This helps you in directly importing JSON data into MongoDB or transferring data from one Mongo collection to another. Sample of document, and you want to remove the field "affLink". The solution to updating documents in nested arrays in mongoDb is to manually find the positional path to the desired document down the nesting order. Document Validation in a Nutshell. find method in the MongoDB Java Synchronous Driver. We created the Neo4j Doc Manager for Mongo Connector to allow MongoDB developers to store JSON data in Mongo while querying the relationships between the data using Neo4j. Intially insert document. Here mycol is our collection name, as created in the previous chapter. RDBMS has fixed number of data type, while MongoDB documents can contains multiple-value field because it has nested structure. 4, original cheatsheet by Derek is outdated. Insert the following documents into a movies collection. A value might be any of the following: A BSON type. By default, MongoDB creates values for the _id field of type ObjectID. js - Insert Document(s) to MongoDB Collection. Referenced documents. MongoDB already has a perfectly good (and much faster) mongoimport program that is available for free in the standard MongoDB community download. In MongoDB, a document is a big JSON blob with no particular format or schema. MongoDB has rapidly grown to become an ideal choice of databases for the number of reasons. With MongoDB, you can embed documents within documents. To insert a record, or document as it is called in MongoDB, into a collection, we use the insertOne() method. Runs on Windows, OS X, Linux and Solaris. MongoDB is an open source, document-oriented, NoSQL database It provides high performance, high availability and automatic scalability. ทำความรู้จักกับ data models ของ MongoDB เบื้องต้น. The following example shows how this can be done, Step 1) Create a JavaScript variable called myEmployee to hold the array of. Each document is provided as a parameter. MongoDB Upsert – Bulk Update or Insert JSON documents. the search is only one level deep. insertOne(doc);. Also, the same serialisation rules specify how a BSON document is mapped to a C# object. If you need to create additional connections, use mongoose. Today we will look into MongoDB update and different options provided by Mongo Shell and Java driver. MongoDB Sort Documents - To sort documents in a collection based on a field, use cursor. A numerically indexed array is stored as an array in case the keys start at 0 and are not interrupted, and as an object if the array keys don't start at 0 or have gaps (ie: 0, 1, 4, 5). Then we would work on how to update an existing document in MongoDB using pymongo library in python. MongoDB Tutorial #16 - Nesting Sub Documents The Net Ninja. Multikey indexes support efficient queries against array fields. MongoDB's Strengths Supporting a different set of fields for each document in a collection is one of MongoDB's features. Document Database– It pairs each key with a complex data structure known as the document. The MongoDB internal JSON parser and the mongo shell can parse this mode. How do I insert a document into MongoDB collection? By Wayan Saryada in MongoDB Last modified: February 1, 2016 1 Comment In the last MongoDB example, How documents are represented in MongoDB Java Driver? , we've seen how MongoDB JSON documents are represented in MongoDB Java driver. Specify the document to insert as a structure. MongoDB Exercise in mongo shell. I have a document in mongodb collection like this: { _id: 133, Name: "abc", Price: 20 } I would like to add a new field "PackSizes" which may be or not may be of an array type, and then would like to an embedded document in it. What is an Embedded MongoDB Document? At this point, we’re just about ready to dive into some code examples, but first, let’s take a moment to understand embedded documents and how they work. The above document sample contains a key named “message” with a value of “Hello, MongoDB”. If you need to create additional connections, use mongoose. below is mongodb document looks How to use auto increment field in insert for CI 3;. MongoDB is a leading document-based NoSQL database. In last tutorial, we learned about MongoDB insert with Mongo Shell and Java driver. insert ( mongodb indexing on nested. Switch to a MongoDB database. Updating Inside a Nested Array with the MongoDB Positional Operator in C# Sometimes you have a document in MongoDB with a property that is an array of nested objects. c#,mongodb,mongodb-csharp. There is also no concept of Isolation, which. jar to be present in the classpath. This topic is about building C# objects that can be serialised into BSON documents and back. Documents of any structure can be stored in the same collection without a defined schema. Specify the document to insert as a structure. Multikey indexes can be created on an array field that contains either scalar values (in other words string or Integer) or nested documents. Lets see some examples "somearray1" : [ { ";playerStatus". These bulks operation are available since MongoDB 2. Both are used for storing the data and free to use that is both comes under open-sources software. Models in Mongoose perform the bulk of the work of establishing up default values for document properties and validating data. Hi all my aim is to perform push,pull and addtoset in multi nested array. I am trying to insert nested documents in to a MongoDB using C#. In MongoDB, each document has "_id" field as a primary key which should have an unique value. MongoDB C# Driver Cheat Sheet (C) 2015 by Derek Hunziker, (C) 2017 by AppsOn. In MongoDB an object inside a document is called as a nested document. Usage of Find by ID, Find in Array, Find all, Find and Update with examples. Like JSON, MongoDB's BSON implementation supports embedding objects and arrays within other objects and arrays - MongoDB can even 'reach inside' BSON objects to build indexes and match objects against query expressions on both top-level and nested BSON keys. If the selection query is not matched then it will insert a new document with the values. Unlike an RDBMS record which is "flat" (a fixed number of simple data type), the basic unit of MongoDb is "document" which is "nested" and can contain multi-value fields (arrays, hash). Classified as a NoSQL database program, MongoDB uses JSON -like documents with schema. As of releasing MongoDB 3. Resources:. To directly insert a document (instead of. Remember that this will only update the first matching item in the attendance array in each document, so you will have to run this update more than once to make it update each attendance item. First, we need to define a connection. What is an Embedded MongoDB Document? At this point, we're just about ready to dive into some code examples, but first, let's take a moment to understand embedded documents and how they work. Resources:. Internally, MongoDB represents JSON documents in binary-encoded format called BSON. There is also no concept of Isolation, which. Mongodb java driver provides functionality to retrieve documents from mongodb using java. Also, the same serialisation rules specify how a BSON document is mapped to a C# object. When subobj is complex, the query can become large very quickly. The JSON files contained in the file schema store are in a format that can be inserted into a MongoDB schema store (as long as the typeName in the file is unique to the document collection ). They present a single structure, with related data embedded as sub-documents and arrays, collapsing what are otherwise separate parent-child tables linked by foreign keys in a relational database. Run this command to unzip the MongoDB installation: tar -xzvf mongodb-osx-x86_64-2. Our MongoDB tutorial includes all topics of MongoDB database such as insert documents, update documents, delete documents, query documents, projection, sort() and limit() methods, create a collection, drop collection, etc. Learn the top 10 most common commands for MongoDB beginners, including the command to log into MongoDB, show all databases, and select a database to work with. These bulks operation are available since MongoDB 2. Here, the collection represents employee data. If the selection query is matched then it will update the values associated to it. To insert data into MongoDB collection, you need to use MongoDB's insert() or save() method. This method returns a single document matching a query (or None if there are no matches). Following is the code to insert your sample json string or any other string in mongo db : > try { MongoClient client = new MongoClient(new ServerAddress(";localhost. This field has a number of special characteristics: -Value serves as primary key for collection. In this course on MongoDB and MongoDB Shell, you'll learn: Installation of the MongoDB which will be performed on the Local computer (Mac or Windows), Dedicated or VPS server, MongoDB Atlas - Cloud MongoDB Software as a Service. It is useful when you know there is only one matching document, or are only interested in the first match. This method returns a single document matching a query (or None if there are no matches). • If the candidate plans include only ordered query plans, there is a single common results buffer. Lets see some examples "somearray1" : [ { ";playerStatus". When subobj is complex, the query can become large very quickly. MongoDB stores all documents in collections. An array list, as the name implies, is an array. In last tutorial, we learned about MongoDB insert with Mongo Shell and Java driver. In that collection there must exist documents with 2 array, one named categories and one named standards. MongoDB Exercise in mongo shell. Any JSON parser can parse these strict mode representations as key/value pairs; however, only the MongoDB internal JSON parser recognizes the type information conveyed by the format. DOC files• A document is essentially an associative array• Document == JSON object• Document == PHP Array• Document == Python Dictionary• Document == Ruby Hash• etc. Each document in a collection can have a unique set of fields, and those fields can be added or removed from documents once they are inserted which makes document databases, and MongoDB in particular, an excellent. An example of this would be a [code ]person[/code] collection's document with an object called as [code ]address[/code] and might look like this: [code]{ _id: 129, name: "Pra. Loading Unsubscribe from The Net Ninja? Cancel Unsubscribe. First, we need to define a connection. Intially insert document. This is very efficient and seems good at first. Most of the documents always contain a better complete structure which contain multiple and nested key-value pairs. Let's understand this behavior. How to insert document or fields in nested documents in mongo. To directly insert a document (instead of. Regarding MongoDB and ACID, as per this response: "One thing you lose with MongoDB is multi-collection (table) transactions. MongoDB Aggregation. The Nested Sets pattern stores each tree node in a document; in addition to the tree node, document stores the id of node’s parent, the node’s initial stop in the left field, and its return stop in the right field. For example, suppose you wanted to know what is the count of documents in a collection as per the query fired, then MongoDB provides the count() function. Update sub document in MongoDB using asp. jar to be present in the classpath. We would first understand how to insert a document/entry in a collection of a database. In MongoDB, To insert a single document into a collection you can use the insertOne() method. We'll look at some of the different types of validation available in MongoDB, and provide a practical working example of validations in action. There are also two methods "db. find({"packaging. 4, original cheatsheet by Derek is outdated. Would it be possible to flatten the data and put the objects from parent and child in one single table? Therefore, user won't need to modify their mongo json structure in order to make Teiid to work with it. Following is the code to insert your sample json string or any other string in mongo db : > try { MongoClient client = new MongoClient(new ServerAddress(";localhost. Previously we saw how to insert data in mongodb using java. MongoDB stores data in the form of documents, which are JSON-like field and value pairs. In the previous part of this series we looked at write concerns, write acknowledgements and replacing documents with the Save method. mongo Shell mode. If an object is used, it may not have protected or private properties. This value is defined in BSON spec and it’s structured this way:. How to insert nested JSON arrays into a table? 2. If your app uses only one database, you should use mongoose. If the parameter is set to true then. Each document in a collection can have a unique set of fields, and those fields can be added or removed from documents once they are inserted which makes document databases, and MongoDB in particular, an excellent. All write operations in MongoDB are atomic on the level of a single document. In this tutorial, we show you 4 ways to insert below JSON data into a “document“, via Java MongoDB API. Currently, it seems like ID needs to be appear in parent and child for nested documents. Question: Can you help me to create a nested family via the API? I have a column family and a shelf family stored in RFA files, and I would like to implement a command which creates a new family with column and the shelf, and load it into a project. Uh oh, MongoDB can only understand a single positional operator per statement. Since, I wouldn't query for the Nth document, but for a given field in the subdocument, for example. Add new field to every document in a MongoDB. MongoDB returns a query result in batches, and the batch size will not exceed the maximum size of a BSON document. Just as Bigtable leverages the distributed data storage provided by the Google File System, Apache HBase provides Bigtable-like capabilities on top of Hadoop and HDFS. If an inserted document omits the _id field, the MongoDB driver automatically generates an ObjectId for the _id field. In the left-hand MongoDB Compass navigation pane, click: the database to which your target collection belongs. [/code] [code ]{[/code] [code ] "_id": ObjectId("5099803df3. For example, if we want to replace the above example document representing a customer we can execute the following command in a MongoDB client: Identify a document by its internal ID and replace it entirely. MongoDB Sort Documents. See » Specify arrayFilters for Array Update Operations in the MongoDB manual for more information. Update a nested array of a record in mongodb collection. The application visits each node in the tree twice; first during the initial trip, and second during the return trip. bundle":1200}) which would run just fine with MongoDB. The concept of aggregation is to carry out a computation on the results which are returned in a query. Remember that this will only update the first matching item in the attendance array in each document, so you will have to run this update more than once to make it update each attendance item. When you need to insert a batch of documents into a MongoDB collection, creating a Python script is a good way to get the job done. 4 and C# Driver v2. In this example we'll see how to insert a document in MongoDB. This page provides examples of query operations on embedded/nested documents using the MongoDB::Collection::find() method in the MongoDB Perl Driver. Apache HBase is an open-source, distributed, versioned, non-relational database modeled after Google's Bigtable: A Distributed Storage System for Structured Data by Chang et al. Embedding arrays in documents is a great example of this. Insert 5 dummy documents for testing. Presentation can be switched in the Results Viewer toolbar. save() a model) use mongo_insert_one() Contribute. To create a new query plan, the query optimizer: 37 MongoDB Documentation, Release 2. 2: Load the just inserted document. Document Database– It pairs each key with a complex data structure known as the document. With a single command you can insert a document in the collection and the MongoDB creates that collection on. This interface defines a fluent API to add multiple single operations or list of similar operations in sequence which can then eventually be executed by calling. In Studio 3T, the In-Place Data Editing feature takes care of most updates to a single document. Insert embedded/nested document. With MongoDB, we can structure related data by embedded documents. All data stored in the collection are in BSON format. I am having some troule in updating the records in mongoDB collection. We said that Save() works as an Insert if the document ID is not found. Returns an array containing the constants of this enum type, in the order they are declared. It was developed from an idea in 2007 and its first version was released in 2010. version is set to 0. findOne())" && \ mongoexport --csv. The following example JSON document in MongoDB. As of version 3. MongoDB Queries: Query Array of Nested Documents This website uses cookies to ensure you get the best experience on our website. The documents stored in MongoDB are JSON-like. If you specify an _id field, it performs an update with { upsert: true }, meaning, it creates a new document if no document matches the query. Document Database– It pairs each key with a complex data structure known as the document. update()" method and "db. Insert Into Collection. Regarding MongoDB and ACID, as per this response: "One thing you lose with MongoDB is multi-collection (table) transactions. Hi all my aim is to perform push,pull and addtoset in multi nested array. I am new to mongoDB. Joins are not supported therefore if your entities are more-or-less self-contained and do not need cross-referencing or looking up other entities, you may say mongodb is a fit. The update() method updates the values in the existing document while the save() method replaces the existing document with the document passed in save() method. MongoDB update is used to update document in a collection. For example, if we want to replace the above example document representing a customer we can execute the following command in a MongoDB client: Identify a document by its internal ID and replace it entirely. You might build a spreadsheet proposal, for example, with one tab displaying the spreadsheet numbers and formulas, a second tab showing an embedded Word document with the proposal text and even a third tab with a custom logo and signature sheet. An embedded, or nested, MongoDB Document is a normal document that’s nested inside another document within a MongoDB collection. You don't need to create the collection first. MongoDB has rapidly grown to become an ideal choice of databases for the number of reasons. MongoDB Insert Document using insert() Example Here we are inserting a document into the collection named “beginnersbook”. In MongoDB push appends to an exisiting array within a document (remember when creating the post I initialized the comment collection to be a new list). Working Subscribe Subscribed Unsubscribe 349K. 3 Insert Documents using a For Loops or JavaScript Function. The above output shows that two documents have fetched from the collection "userdetails" but only the data of user_id, password and date_of_join have appeared for those documents who have the qualification "M. The field "course" in the example below is an array that holds the several key-value pairs. Updating Inside a Nested Array with the MongoDB Positional Operator in C# Sometimes you have a document in MongoDB with a property that is an array of nested objects. With MongoDB, you can embed documents within documents. NET MVC and MongoDb MongoDb is a schema free, scalable, high performance document database. In MongoDB, a document is a big JSON blob with no particular format or schema. I am new to mongodb and c# and I am trying to insert nested documents in mongoDB using c#, I can insert CompanyName, Address etc, but when it comes to add key contacts I have no idea how to do it, user will enter key contacts into grid view so it might be one or more than one. Update an existing document or insert a document depending on the parameter. sort() method. A document. I dont want this behavior but i need something like mysql's insert or ignore so mongoDB should not insert the document with duplicate url and continue with the next documents. So when you read that MongoDB is a document store, you might get the wonderful idea to store your relationships in a big document. Each document is provided as a parameter. js Application, using insertOne() and insertMany() method respectively, with examples. Updating Inside a Nested Array with the MongoDB Positional Operator in C# Sometimes you have a document in MongoDB with a property that is an array of nested objects. bundle":1200}) which would run just fine with MongoDB. Please see my models below. How to insert nested JSON arrays into a table? 2. In MongoDB terminology, a collection is a group of documents that are stored together within the database. In this tutorial, we show you 4 ways to insert below JSON data into a “document“, via Java MongoDB API. In the previous part of this series we looked at write concerns, write acknowledgements and replacing documents with the Save method. mapReduce, map reduce, map/reduce grid, shard cluster, set, deployment. partialFilterExpression : A document that specifies a filter for a partial index. Method 1: Creating the Collection in MongoDB on the fly. Update sub document in MongoDB using asp. When subobj is complex, the query can become large very quickly. Nested tables are a way for you to organize objects, such as images or. A document in MongoDB is the same as a record in MySQL The first parameter of the insertOne() method is an object containing the name(s) and value(s) of each field in the document you want to insert. The dot notation becomes tedious pretty quickly, as you need to write code to flatten the sub-objects to generate the update values. c# mongodb driver groupby. Insertion happens asynchronously and operations dependent on the inserted document has to be taken care. Usage of Find by ID, Find in Array, Find all, Find and Update with examples. Documents in a collection are analogous to rows in a relational database table. Bulk operations for insert/update/remove actions on a collection. If the collection doesn't exist in the database, then MongoDB will create this collection and then insert a document into it. 2 In MongoDB, insert operations target a single collection. Update a nested array of a record in mongodb collection. When you need to insert a batch of documents into a MongoDB collection, creating a Python script is a good way to get the job done. Insert only accepts a final document or an array of documents, and an optional object which contains additional options for the collection. For a more in-depth look, have a look at the introductory MongoDB article. It offers Ad hoc queries, Indexing, Replication, Load balancing, File storage (GridFS), Aggregation, MapReduce and Server-side JavaScript execution. The query returns all persons who love either apples or oranges or both.