SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
ArangoDB

/* Using Javascript
   in the database */

 Jan Steemann, triAGENS, Cologne
ArangoDB
  basics



www.arangodb.org © j.steemann@triagens.de
ArangoDB.explain()

{
    "type":             "NoSQL database",
    "openSource": true,
    "version":          1.0,
    "builtWith": [ "C", "C++", "js" ],
    "Javascript": [ "client side",
                "server side" ],
    "uses":             [ "V8" ]
}

                  www.arangodb.org © j.steemann@triagens.de
Documents
      and collections
ArangoDB is a database that works with
documents

Documents are sets of name / value pairs
(think of JSON objects), e.g.

{ "name": "Jan", "age": 37 }

Documents are organised in collections (like
tables in relational databases)

           www.arangodb.org © j.steemann@triagens.de
Data types: JSON!

ArangoDB operates on JSON documents

JSON data can be saved as-is:

db.users.save({
  "name": "Jan",
  "uses": [ "vi", "js", "C++" ]
});


            www.arangodb.org © j.steemann@triagens.de
Schema-free
Documents can be heterogenous –
even in the same collection, e.g.

{ "name": "Jan", "age": 37 },
{ "name": "Tim", "likes": [ "js" ] },
{ "name": {
    "first": "Patrick",
    "last": "Star"
  }
}

No need to care about schemas
              www.arangodb.org © j.steemann@triagens.de
API & protocols
ArangoDB server functionality is exposed via an
HTTP REST API

ArangoDB answers HTTP queries,
so it can be used from the browser

Simple to use from Javascript clients

(3rd party) drivers available for node.js, Ruby,
PHP, ...

Javascript-enabled client shell provided

           www.arangodb.org © j.steemann@triagens.de
Querying



www.arangodb.org © j.steemann@triagens.de
Querying is simple

Query a document by its unique id / key:
db._document("users/9558905");

Query by providing an example:
db.users.byExample({
  "name": "Jan",
  "age": 37
});



          www.arangodb.org © j.steemann@triagens.de
Indexes
ArangoDB allows querying on any document
attributes or sub-attributes

Secondary indexes can be created for higher
query performance:
•   Hash indexes (equality queries)
•   Skiplists (range queries)
•   2d geo indexes (location queries)

            www.arangodb.org © j.steemann@triagens.de
Geo index examples


// get b a r n ea r es t t o coor d in a t e
db.bars.near(48.51, 2.21).limit(1);

// get a ll s h op s w it h in r a d iu s
// a r ou n d coor d in a t e
db.shops.within(48.51, 2.21, rad);



               www.arangodb.org © j.steemann@triagens.de
References
ArangoDB can store references between
documents

References are documents with two endpoints
(the documents they connect)

Reference documents can carry own attributes




          www.arangodb.org © j.steemann@triagens.de
References example
Users documents:                                     Relations documents:
                                                     (references)
{
    "name": "Jan",
    "age": 37                                        {
}                                                        "_from": "users/jan",
                                                         "_to": "users/tim",
{                                                        "type": "knows",
    "name": "Tim",                                   }
    "city": "Paris"
}

// q u er y ou t b ou n d r ela t ion s f r om "J a n "
db.relations.outEdges(jan); // => tim
                      www.arangodb.org © j.steemann@triagens.de
Graph queries

References make it possible to process graphs
with ArangoDB

Some special functions are provided to
determine paths in a graph etc.

Can write own Javascript functions for special
traversals


          www.arangodb.org © j.steemann@triagens.de
Query language

ArangoDB can also answer complex
SQL-like queries

Such queries are expressed in ArangoDB's
textual query language

This language allows joins, sub-queries,
aggregation etc.


          www.arangodb.org © j.steemann@triagens.de
Example query
FOR u IN users                                             It er a t or
 FILTER u.addr.country == "US" &&
       (u.isConfirmed == true ||
        u.age >= 18)                                          F ilt er
 LET userLogins = (
   FOR l IN logins
     FILTER l.userId == u.id
     RETURN l
 )                                                       S u b q u er y
 RETURN {
   "user":     u,
   "logins": LENGTH(userLogins)
 }                                                           R es u lt
             www.arangodb.org © j.steemann@triagens.de
Server side „actions“



     www.arangodb.org © j.steemann@triagens.de
Application server

ArangoDB can answer web requests directly

This also makes it an application server

Users can extend its functionality with server
side Javascript „actions“

Actions are user-defined functions that contain
custom business logic


           www.arangodb.org © j.steemann@triagens.de
Actions


Actions are bound to URLs and executed when
URLs are called, e.g.

/users?name=... => function(...)
/users/.../friends => function(...)




           www.arangodb.org © j.steemann@triagens.de
Actions example
function (req, res) {
  // get r eq u es t ed u s er f r om d b ,
  // n a m e is r ea d f r om U R L p a r a m et er
 var u = db.users.byExample({
   "username": req.urlParameters.name
 });

    // r em ov e p a s s w or d h a s h
    delete u.hashedPassword;

    // b ef or e r et u r n in g t o ca ller
    actions.resultOk(req, res, 200, u);
}
                    www.arangodb.org © j.steemann@triagens.de
Actions – Use cases
Filter out sensitive data before responding

Validate input

Check privileges

Check and enforce constraints

Aggregate data from multiple queries into a single
response

Carry out data-intensive operations

           www.arangodb.org © j.steemann@triagens.de
Summary



www.arangodb.org © j.steemann@triagens.de
ArangoDB - summary
Flexible in terms of data modelling and querying

API is based on web standards:
HTTP, REST, JSON

Easy to use from Javascript clients

Can be used as application server

Functionality can be extended with server side
Javascript „actions“

          www.arangodb.org © j.steemann@triagens.de
Thanks!
          Any questions?
Спасибо                                                      Grazie

Teşekkürler                                                ¡Gracias!

Merci!                                                       Хвала

Dank je wel                                               Ευχαριστώ

ありがとう                                                        고마워

Tack så mycket                                               Danke

              www.arangodb.org © j.steemann@triagens.de
Give it a try!
ArangoDB source repository:
https://www.github.com/triAGENS/ArangoDB
(use master branch)

Website: http://www.arangodb.org/

Builds available for Homebrew and
several Linux distributions

Twitter: #arangodb, @arangodb

Google group: ArangoDB
           www.arangodb.org © j.steemann@triagens.de
Roadmap


MVCC / ACID transactions

Triggers

Synchronous and asynchronous replication




           www.arangodb.org © j.steemann@triagens.de
Thank you!
Stay in Touch:
 •   Fork me on github
 •   Google Group: ArangoDB
 •   Twitter: @steemann & @arangodb
 •   www.arangodb.org



                 www.arangodb.org © j.steemann@triagens.de

Contenu connexe

Tendances

Query mechanisms for NoSQL databases
Query mechanisms for NoSQL databasesQuery mechanisms for NoSQL databases
Query mechanisms for NoSQL databases
ArangoDB Database
 
Small Overview of Skype Database Tools
Small Overview of Skype Database ToolsSmall Overview of Skype Database Tools
Small Overview of Skype Database Tools
elliando dias
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsing
Jussi Pohjolainen
 
Introduction to column oriented databases
Introduction to column oriented databasesIntroduction to column oriented databases
Introduction to column oriented databases
ArangoDB Database
 
Introduction to couch_db
Introduction to couch_dbIntroduction to couch_db
Introduction to couch_db
Romain Testard
 

Tendances (20)

Query mechanisms for NoSQL databases
Query mechanisms for NoSQL databasesQuery mechanisms for NoSQL databases
Query mechanisms for NoSQL databases
 
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
A Graph Database That Scales - ArangoDB 3.7 Release WebinarA Graph Database That Scales - ArangoDB 3.7 Release Webinar
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
 
OrientDB: Unlock the Value of Document Data Relationships
OrientDB: Unlock the Value of Document Data RelationshipsOrientDB: Unlock the Value of Document Data Relationships
OrientDB: Unlock the Value of Document Data Relationships
 
OrientDB & Node.js Overview - JS.Everywhere() KW
OrientDB & Node.js Overview - JS.Everywhere() KWOrientDB & Node.js Overview - JS.Everywhere() KW
OrientDB & Node.js Overview - JS.Everywhere() KW
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
 
Graph Databases & OrientDB
Graph Databases & OrientDBGraph Databases & OrientDB
Graph Databases & OrientDB
 
Small Overview of Skype Database Tools
Small Overview of Skype Database ToolsSmall Overview of Skype Database Tools
Small Overview of Skype Database Tools
 
Solid pods and the future of the spatial web
Solid pods and the future of the spatial webSolid pods and the future of the spatial web
Solid pods and the future of the spatial web
 
Using Webservice in iOS
Using Webservice  in iOS Using Webservice  in iOS
Using Webservice in iOS
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsing
 
PostgreSQL - Object Relational Database
PostgreSQL - Object Relational DatabasePostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
 
Introduction to column oriented databases
Introduction to column oriented databasesIntroduction to column oriented databases
Introduction to column oriented databases
 
State of the Semantic Web
State of the Semantic WebState of the Semantic Web
State of the Semantic Web
 
RDFa Tutorial
RDFa TutorialRDFa Tutorial
RDFa Tutorial
 
elasticsearch basics workshop
elasticsearch basics workshopelasticsearch basics workshop
elasticsearch basics workshop
 
ODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XMLODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XML
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 
The Lonesome LOD Cloud
The Lonesome LOD CloudThe Lonesome LOD Cloud
The Lonesome LOD Cloud
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
Introduction to couch_db
Introduction to couch_dbIntroduction to couch_db
Introduction to couch_db
 

En vedette

ArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQLArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQL
ArangoDB Database
 
Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater
Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater
Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater
Neo4j
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
Peter Neubauer
 

En vedette (12)

ArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQLArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQL
 
Lokijs
LokijsLokijs
Lokijs
 
Domain Driven Design and NoSQL TLV
Domain Driven Design and NoSQL TLVDomain Driven Design and NoSQL TLV
Domain Driven Design and NoSQL TLV
 
ArangoDB
ArangoDBArangoDB
ArangoDB
 
Converting Relational to Graph Databases
Converting Relational to Graph DatabasesConverting Relational to Graph Databases
Converting Relational to Graph Databases
 
Designing and Building a Graph Database Application – Architectural Choices, ...
Designing and Building a Graph Database Application – Architectural Choices, ...Designing and Building a Graph Database Application – Architectural Choices, ...
Designing and Building a Graph Database Application – Architectural Choices, ...
 
Working With a Real-World Dataset in Neo4j: Import and Modeling
Working With a Real-World Dataset in Neo4j: Import and ModelingWorking With a Real-World Dataset in Neo4j: Import and Modeling
Working With a Real-World Dataset in Neo4j: Import and Modeling
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater
Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater
Neo4j Partner Tag Berlin - Potential für System-Integratoren und Berater
 
Webinar: RDBMS to Graphs
Webinar: RDBMS to GraphsWebinar: RDBMS to Graphs
Webinar: RDBMS to Graphs
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
 

Similaire à ArangoDB - Using JavaScript in the database

Similaire à ArangoDB - Using JavaScript in the database (20)

Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
 
Dex Technical Seminar (April 2011)
Dex Technical Seminar (April 2011)Dex Technical Seminar (April 2011)
Dex Technical Seminar (April 2011)
 
aRangodb, un package per l'utilizzo di ArangoDB con R
aRangodb, un package per l'utilizzo di ArangoDB con RaRangodb, un package per l'utilizzo di ArangoDB con R
aRangodb, un package per l'utilizzo di ArangoDB con R
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Bringing your app to the web with Dart - Chris Buckett (Entity Group)
Bringing your app to the web with Dart - Chris Buckett (Entity Group)Bringing your app to the web with Dart - Chris Buckett (Entity Group)
Bringing your app to the web with Dart - Chris Buckett (Entity Group)
 
Stop the noise! - Introduction to the JSON:API specification in Drupal
Stop the noise! - Introduction to the JSON:API specification in DrupalStop the noise! - Introduction to the JSON:API specification in Drupal
Stop the noise! - Introduction to the JSON:API specification in Drupal
 
Introduction to Spark Datasets - Functional and relational together at last
Introduction to Spark Datasets - Functional and relational together at lastIntroduction to Spark Datasets - Functional and relational together at last
Introduction to Spark Datasets - Functional and relational together at last
 
Go react codelab
Go react codelabGo react codelab
Go react codelab
 
django
djangodjango
django
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 

Plus de ArangoDB Database

Plus de ArangoDB Database (20)

ATO 2022 - Machine Learning + Graph Databases for Better Recommendations (3)....
ATO 2022 - Machine Learning + Graph Databases for Better Recommendations (3)....ATO 2022 - Machine Learning + Graph Databases for Better Recommendations (3)....
ATO 2022 - Machine Learning + Graph Databases for Better Recommendations (3)....
 
Machine Learning + Graph Databases for Better Recommendations V2 08/20/2022
Machine Learning + Graph Databases for Better Recommendations V2 08/20/2022Machine Learning + Graph Databases for Better Recommendations V2 08/20/2022
Machine Learning + Graph Databases for Better Recommendations V2 08/20/2022
 
Machine Learning + Graph Databases for Better Recommendations V1 08/06/2022
Machine Learning + Graph Databases for Better Recommendations V1 08/06/2022Machine Learning + Graph Databases for Better Recommendations V1 08/06/2022
Machine Learning + Graph Databases for Better Recommendations V1 08/06/2022
 
ArangoDB 3.9 - Further Powering Graphs at Scale
ArangoDB 3.9 - Further Powering Graphs at ScaleArangoDB 3.9 - Further Powering Graphs at Scale
ArangoDB 3.9 - Further Powering Graphs at Scale
 
GraphSage vs Pinsage #InsideArangoDB
GraphSage vs Pinsage #InsideArangoDBGraphSage vs Pinsage #InsideArangoDB
GraphSage vs Pinsage #InsideArangoDB
 
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
 
Graph Analytics with ArangoDB
Graph Analytics with ArangoDBGraph Analytics with ArangoDB
Graph Analytics with ArangoDB
 
Getting Started with ArangoDB Oasis
Getting Started with ArangoDB OasisGetting Started with ArangoDB Oasis
Getting Started with ArangoDB Oasis
 
Custom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDBCustom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDB
 
Hacktoberfest 2020 - Intro to Knowledge Graphs
Hacktoberfest 2020 - Intro to Knowledge GraphsHacktoberfest 2020 - Intro to Knowledge Graphs
Hacktoberfest 2020 - Intro to Knowledge Graphs
 
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
 
ArangoML Pipeline Cloud - Managed Machine Learning Metadata
ArangoML Pipeline Cloud - Managed Machine Learning MetadataArangoML Pipeline Cloud - Managed Machine Learning Metadata
ArangoML Pipeline Cloud - Managed Machine Learning Metadata
 
ArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB 3.7 Roadmap: Performance at ScaleArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB 3.7 Roadmap: Performance at Scale
 
Webinar: What to expect from ArangoDB Oasis
Webinar: What to expect from ArangoDB OasisWebinar: What to expect from ArangoDB Oasis
Webinar: What to expect from ArangoDB Oasis
 
ArangoDB 3.5 Feature Overview Webinar - Sept 12, 2019
ArangoDB 3.5 Feature Overview Webinar - Sept 12, 2019ArangoDB 3.5 Feature Overview Webinar - Sept 12, 2019
ArangoDB 3.5 Feature Overview Webinar - Sept 12, 2019
 
3.5 webinar
3.5 webinar 3.5 webinar
3.5 webinar
 
Webinar: How native multi model works in ArangoDB
Webinar: How native multi model works in ArangoDBWebinar: How native multi model works in ArangoDB
Webinar: How native multi model works in ArangoDB
 
An introduction to multi-model databases
An introduction to multi-model databasesAn introduction to multi-model databases
An introduction to multi-model databases
 
Running complex data queries in a distributed system
Running complex data queries in a distributed systemRunning complex data queries in a distributed system
Running complex data queries in a distributed system
 
Guacamole Fiesta: What do avocados and databases have in common?
Guacamole Fiesta: What do avocados and databases have in common?Guacamole Fiesta: What do avocados and databases have in common?
Guacamole Fiesta: What do avocados and databases have in common?
 

Dernier

Dernier (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 

ArangoDB - Using JavaScript in the database

  • 1. ArangoDB /* Using Javascript in the database */ Jan Steemann, triAGENS, Cologne
  • 2. ArangoDB basics www.arangodb.org © j.steemann@triagens.de
  • 3. ArangoDB.explain() { "type": "NoSQL database", "openSource": true, "version": 1.0, "builtWith": [ "C", "C++", "js" ], "Javascript": [ "client side", "server side" ], "uses": [ "V8" ] } www.arangodb.org © j.steemann@triagens.de
  • 4. Documents and collections ArangoDB is a database that works with documents Documents are sets of name / value pairs (think of JSON objects), e.g. { "name": "Jan", "age": 37 } Documents are organised in collections (like tables in relational databases) www.arangodb.org © j.steemann@triagens.de
  • 5. Data types: JSON! ArangoDB operates on JSON documents JSON data can be saved as-is: db.users.save({ "name": "Jan", "uses": [ "vi", "js", "C++" ] }); www.arangodb.org © j.steemann@triagens.de
  • 6. Schema-free Documents can be heterogenous – even in the same collection, e.g. { "name": "Jan", "age": 37 }, { "name": "Tim", "likes": [ "js" ] }, { "name": { "first": "Patrick", "last": "Star" } } No need to care about schemas www.arangodb.org © j.steemann@triagens.de
  • 7. API & protocols ArangoDB server functionality is exposed via an HTTP REST API ArangoDB answers HTTP queries, so it can be used from the browser Simple to use from Javascript clients (3rd party) drivers available for node.js, Ruby, PHP, ... Javascript-enabled client shell provided www.arangodb.org © j.steemann@triagens.de
  • 9. Querying is simple Query a document by its unique id / key: db._document("users/9558905"); Query by providing an example: db.users.byExample({ "name": "Jan", "age": 37 }); www.arangodb.org © j.steemann@triagens.de
  • 10. Indexes ArangoDB allows querying on any document attributes or sub-attributes Secondary indexes can be created for higher query performance: • Hash indexes (equality queries) • Skiplists (range queries) • 2d geo indexes (location queries) www.arangodb.org © j.steemann@triagens.de
  • 11. Geo index examples // get b a r n ea r es t t o coor d in a t e db.bars.near(48.51, 2.21).limit(1); // get a ll s h op s w it h in r a d iu s // a r ou n d coor d in a t e db.shops.within(48.51, 2.21, rad); www.arangodb.org © j.steemann@triagens.de
  • 12. References ArangoDB can store references between documents References are documents with two endpoints (the documents they connect) Reference documents can carry own attributes www.arangodb.org © j.steemann@triagens.de
  • 13. References example Users documents: Relations documents: (references) { "name": "Jan", "age": 37 { } "_from": "users/jan", "_to": "users/tim", { "type": "knows", "name": "Tim", } "city": "Paris" } // q u er y ou t b ou n d r ela t ion s f r om "J a n " db.relations.outEdges(jan); // => tim www.arangodb.org © j.steemann@triagens.de
  • 14. Graph queries References make it possible to process graphs with ArangoDB Some special functions are provided to determine paths in a graph etc. Can write own Javascript functions for special traversals www.arangodb.org © j.steemann@triagens.de
  • 15. Query language ArangoDB can also answer complex SQL-like queries Such queries are expressed in ArangoDB's textual query language This language allows joins, sub-queries, aggregation etc. www.arangodb.org © j.steemann@triagens.de
  • 16. Example query FOR u IN users It er a t or FILTER u.addr.country == "US" && (u.isConfirmed == true || u.age >= 18) F ilt er LET userLogins = ( FOR l IN logins FILTER l.userId == u.id RETURN l ) S u b q u er y RETURN { "user": u, "logins": LENGTH(userLogins) } R es u lt www.arangodb.org © j.steemann@triagens.de
  • 17. Server side „actions“ www.arangodb.org © j.steemann@triagens.de
  • 18. Application server ArangoDB can answer web requests directly This also makes it an application server Users can extend its functionality with server side Javascript „actions“ Actions are user-defined functions that contain custom business logic www.arangodb.org © j.steemann@triagens.de
  • 19. Actions Actions are bound to URLs and executed when URLs are called, e.g. /users?name=... => function(...) /users/.../friends => function(...) www.arangodb.org © j.steemann@triagens.de
  • 20. Actions example function (req, res) { // get r eq u es t ed u s er f r om d b , // n a m e is r ea d f r om U R L p a r a m et er var u = db.users.byExample({ "username": req.urlParameters.name }); // r em ov e p a s s w or d h a s h delete u.hashedPassword; // b ef or e r et u r n in g t o ca ller actions.resultOk(req, res, 200, u); } www.arangodb.org © j.steemann@triagens.de
  • 21. Actions – Use cases Filter out sensitive data before responding Validate input Check privileges Check and enforce constraints Aggregate data from multiple queries into a single response Carry out data-intensive operations www.arangodb.org © j.steemann@triagens.de
  • 23. ArangoDB - summary Flexible in terms of data modelling and querying API is based on web standards: HTTP, REST, JSON Easy to use from Javascript clients Can be used as application server Functionality can be extended with server side Javascript „actions“ www.arangodb.org © j.steemann@triagens.de
  • 24. Thanks! Any questions? Спасибо Grazie Teşekkürler ¡Gracias! Merci! Хвала Dank je wel Ευχαριστώ ありがとう 고마워 Tack så mycket Danke www.arangodb.org © j.steemann@triagens.de
  • 25. Give it a try! ArangoDB source repository: https://www.github.com/triAGENS/ArangoDB (use master branch) Website: http://www.arangodb.org/ Builds available for Homebrew and several Linux distributions Twitter: #arangodb, @arangodb Google group: ArangoDB www.arangodb.org © j.steemann@triagens.de
  • 26. Roadmap MVCC / ACID transactions Triggers Synchronous and asynchronous replication www.arangodb.org © j.steemann@triagens.de
  • 27. Thank you! Stay in Touch: • Fork me on github • Google Group: ArangoDB • Twitter: @steemann & @arangodb • www.arangodb.org www.arangodb.org © j.steemann@triagens.de