0% found this document useful (0 votes)
50 views9 pages

CodeRageX MongoDB 2

This document provides an agenda and overview for a presentation on advanced MongoDB and FireDAC. The presentation covers topics like indexing, query options, geospatial queries, aggregation pipelines, update operations, and database meta information. Code samples are provided in Object Pascal and resources like documentation links and forums for further learning are listed.

Uploaded by

M AbdulAziz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views9 pages

CodeRageX MongoDB 2

This document provides an agenda and overview for a presentation on advanced MongoDB and FireDAC. The presentation covers topics like indexing, query options, geospatial queries, aggregation pipelines, update operations, and database meta information. Code samples are provided in Object Pascal and resources like documentation links and forums for further learning are listed.

Uploaded by

M AbdulAziz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Advanced MongoDB & FireDAC

Jim McKeeth & Dmitry Arefiev


Embarcadero Technologies
Agenda – The Fun Stuff

• Indexing 2:09 Code Samples are


• Query Options 10:26 all Object Pascal
• Geospatial Queries 12:23 delphi.org/?p=2053
• Aggregation & Pipelines 19:29
• Redact Slides
• Projection delphi.org/coderage
• Grouping
Q&A at 39:03
• Update Operations 27:16
• Database Meta Information 31:31
• Local SQL 33:19

2
Indexing

• _id is indexed by default as _id_


• Other indexes can be added to improve query performance
• MongoDB uses a B-Tree internally for indexing
• Use the Query Option to get an Explain Plan
• Docs
• http://docs.mongodb.org/manual/administration/indexes-creation/
• http://docs.mongodb.org/manual/tutorial/create-an-index/
• http://docs.mongodb.org/manual/tutorial/create-a-compound-index/
• http://docs.mongodb.org/manual/tutorial/list-indexes/
• http://docs.mongodb.org/manual/tutorial/remove-indexes/
• http://docs.mongodb.org/manual/reference/method/cursor.explain/

3
Geospatial Indexes and Queries

• Supports both spherical and planar geometries


– 2d: geometries on a plane
– 2dsphere: geometries of an earth-like sphere
• Query operations
– Within a bounding geometry
– Intersecting geometry
– Near a point
• More information
– http://docs.mongodb.org/manual/applications/geospatial-indexes/
– http://docs.mongodb.org/manual/reference/operator/query-geospatial/

4
Aggregation Pipeline

• Operations that process data along a series of steps


• Change the format of or further process documents resulting from a query
• Documents enter the pipeline and are transformed into an aggregated result
• A less complex alternative to map-reduce (also supported)
• FireDAC supports through the TFDMongoPipeline and Aggregate methods
• References
– http://docs.mongodb.org/manual/aggregation/
– http://docs.mongodb.org/manual/reference/operator/aggregation/

5
Aggregation Example

• Runs through stages


• Typically starts with a match
• Example shows grouping
• Resulting collection contains
modified documents
• Makes documents easier to
work with in program logic
• Underlying collection is
unmodified

6
Update Operations

• Modifies an existing document or documents in a collection.


• Can modify specific fields of an existing document or documents or replace an existing
document entirely.
• Can replace with static or dynamic operator generated values.
• Updates are atomic within a single document.
• More information
– http://docs.mongodb.org/manual/tutorial/modify-documents/
– http://docs.mongodb.org/manual/reference/method/db.collection.update/
– http://docs.mongodb.org/manual/reference/operator/update/inc/
– http://docs.mongodb.org/manual/reference/operator/update/push/

7
Learning Resources


Code Samples
MongoDB Documentation
delphi.org/?p=2053
– docs.mongodb.org/manual/
• MongoDB Skill Sprint

Slides
embt.co/sprint-nosql-mongodb
delphi.org/coderage
• Part 1 from CodeRage X
• DocWiki
– docwiki.embarcadero.com/RADStudio/Seattle/en/What%27s_New#Support_for_the_NoSQL_MongoDB_Database
– docwiki.embarcadero.com/RADStudio/Seattle/en/Connect_to_MongoDB_Database_(FireDAC)
– docwiki.embarcadero.com/CodeExamples/Seattle/en/FireDAC.MongoDB_Explore_Sample
– docwiki.embarcadero.com/Libraries/Seattle/en/FireDAC.Phys.MongoDBWrapper
• Samples
– \Samples\Object Pascal\Database\FireDAC\Samples\DBMS Specific\MongoDB

8
Q&A – Thanks for Joining Us!

The places to communicate:


• Quality.Embarcadero.com
• Embarcadero FireDAC forum
– https://forums.embarcadero.com/forum.jspa?forumID=502
• Email
[email protected] & [email protected]
• Code Samples
– delphi.org/?p=2053
• Slides
– delphi.org/coderage

You might also like