SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
JavaScript & NoSQL
    a Love Story!

   by Alexandre Morgaut
    NoSQL matters - Barcelona 2012
Presentation
W3C AC member

Web Architect

JS Expert

REST Lover

NoSQL Fanboy


  @amorgaut
NoSQL facts
NoSQL Facts

Mostly Schemaless
Often with REST / JSON API
Many store JSON
Many embed a JavaScript engine
  Map / Reduce
  events
Many propose a JavaScript Shell
JavaScript facts
JavaScript Facts

Created in 1995
Running in Netscape Server in 1996, and then in IIS
Mostly Event-Driven
Recommended in the REST definition in 2000
Integrated in CouchDB in 2007
HTML5 Datastores appeared in 2009
JavaScript & Databases
JavaScript & Databases


Netscape Enterprise Server
Microsoft: JScript, JScript.NET, ActiveX
Mozilla Rhino
JSDB
APE Project
W3C Web SQL
Netscape Enterprise Server


   SQLTable()                      pool = new DbPool("ORACLE", addr, user, pwd, "", 5, true);
                                   connection = pool.connection("A connection");

                                   cursor = connection.cursor("select name from customer");
   DbPool                          if ( cursor && (connection.majorErrorCode() == 0) ) {
                                      // Get the first row
                                      cursor.next();

   start/home.html
                                      // Display the values
                                      write("<B>Customer Name:</B> " + cursor.name + "<BR>");
                                      //Close the cursor
                                      cursor.close();
                                   }

   Shared Connections


Note: Netscape Enterprise Server merged with Javagator to become iPlanet
MS JScript on the server


                                    conn = Server.CreateObject("ADODB.Connection");

Active Server Page                  conn.Open(dsn, login, password);

                                    reccordset = conn.Execute(sqlQuery);
                                    result = [];

 runat=”server”                     while (!reccordset.EOF) {

                                        result.push({

Windows Script Hosting
                                            field1: reccordset("field1"),
                                            field2: reccordset("field2")
                                        });
                                        rsAuthor2.MoveNext;


.NET                                }

                                    conn.Close();
                                    conn = null;




    Note: JScript is running on Microsoft IIS since 1997
MS JScript in the Browser


                var connection = new ActiveXObject("ADODB.Connection");
                  
                connection.Open(dsn, login, password);

ActiveXObject
                var reccordset = new ActiveXObject("ADODB.Recordset");
                 
                reccordset.Open(sqlQuery, connection);
                reccordset.MoveFirst;

 only IE        while(!reccordset.eof) {
                   document.write(reccordset.fields(1));
                   reccordset.movenext;
                }
                 
                reccordset.close;
                connection.close;
Mozilla Rhino


                                importPackage(java.sql);
                                java.lang.Class.forName("org.sqlite.JDBC");

Java environment                conn = DriverManager.getConnection("jdbc:sqlite:test.db");
                                stat = conn.createStatement();
                                resultSet = stat.executeQuery("select * from people;");


Access to JDBC                  while (resultSet.next()){
                                    print(
                                        resultSet.getString("name") +
                                        " - " +

ex: RingoJS
                                        resultSet.getString("occupation")
                                    );
                                }

                                resultSet.close();
                                stat.close();
                                conn.close();




              https://developer.mozilla.org/en-US/docs/Rhino
JSDB


                              var db = new ODBC(dsn);
                              var result = db.query("select * from mytable");


SpiderMonkey                  var searcher = new Index;
                              for (var i=1; i <= result.count; i++)
                              {
                                searcher.add(result.get('NAME'));

Shell
                              }

                              var i = searcher.find('Mr. Smith');
                              var r = result.getRow(i + 1);


JS Server                     writeln('Data for Mr. Smith');
                              writeln(r.toString());

                              db.close();




               http://www.jsdb.org/
APE Project

                            var sql = new Ape.MySQL(ip + ":3306", user, password, db);

                            Ape.registerCmd('foo', true, function(params, cmd) {
Real Time Web                     cmd.user.sendRaw(
                                      'bar', {
                                          hello: 'world',

 Comet                            );
                                      }
                                          echo: params.ping



                                  sql.query(

 Web Sockets                          'INSERT INTO table(log) VALUES("' +
                                      Ape.MySQL.escape(params.ping) +
                                      '")',
                                      function(res, errorNo) {

MySQL
                                          Ape.log('Inserted ' + this.getInsertId());
                                      }
                                  );
                            });




         Note: APE means “Ajax Push Engine”
                   http://www.ape-project.org/
W3C Web SQL


       HTML5                var db = openDatabase('mydb', '1.0', 'my first db', 2 * 1024 * 1024);




          Safari
                         db.transaction(function (tx) {
                           tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
                           tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "synergies")');
                         });


          Chrome                  tx.executeSql('SELECT * FROM foo', [], function (tx, results) {
                                    for (var i = 0, len = results.rows.length; i < len; i++) {
                                      alert(results.rows.item(i).text);

          Opera                     }
                                  });




       Sync / Async
                                         result = x.executeSqlSync('SELECT * FROM foo');
                                         for (var i = 0, len = results.rows.length; i < len; i++) {
                                           alert(results.rows.item(i).text);
                                         }



Note: standard paused because current implementations are only based on SQLite
                         http://html5doctor.com/introducing-web-sql-databases/
Hiding SQL
Hiding SQL


GData




OData
Touching the DB heart
Touching the DB Heart


Key-Value: Web Storage, Riak

Document: CouchDB, MongoDB, IndexedDB

Object: JavaScriptDB, WakandaDB

Multi-Model: OrientDB & ArangoDB
Key - Value
Web Storage


   W3C / WHATWG                             // set or get items by methods
                                            localStorage.setItem("storedItem", "value");
                                            var value = localStorage.getItem("storedItem");



      HTML5                                        // set or get items using the store as a map
                                                   localStorage.storedItem = value;
                                                   var value = localStorage.storedItem;


   local                                           // accessible only for this session
                                                   var foo = sessionStorage.bar;

   session
                                                   sessionStorage.bar = foo;



                                    // sync interface when data change, even from other window
                                    window.addEventListener("storage", handle_storage, false);
   events

Note: Firefox also implement “globalStorage”, and Wakanda “user.storage”
                          http://www.w3.org/TR/webstorage/
Riak
                                        {"inputs": "goog",

Buckets                                   "query": [
                                            {"map": {"language": "javascript",
                                              "source": "function(value, keyData, arg){...}"
                                            }},

REST / JSON
                                            {"reduce": {"language": "javascript",
                                              "source": "function(values, arg){...}",
                                              "keep": true
                                            }}
                                          ]

Map / Reduce                            }


                                      // Map: compute the daily variance, key it by the month

Erlang alternative:
                                      function(value, keyData, arg){
                                        var data = Riak.mapValuesJson(value)[0];
                                        var month = value.key.split('-').slice(0,2).join('-');
                                        var obj = {};
                                        obj[month] = data.High - data.Low;

  SpiderMonkey                        }
                                        return [ obj ];



          // Reduce: find the maximum variance per month
          function(values, arg) {
            return [values.reduce(function(acc, item){
              for (var month in item) {
                 acc[month] = acc[month] ? Math.max(item[month], acc[month]) : item[month];
              }
              return acc;
            })];
          }


               http://wiki.basho.com/MapReduce-Implementation.html
Document
IndexedDB

                                        var request = indexedDB.open("MyTestDatabase", 3);
W3C / WHATWG
                                              request.onerror =    function(event) {

 HTML5
                                                 // Do something   with request.errorCode!
                                              };
                                              request.onsuccess    = function(event) {
                                                 // Do something   with request.result!
                                              };

Sync / Async                                  request.onupgradeneeded = function(event) {
                                                 // Update object stores and indices ....

Indexes
                                              }



                  var objectStore = db.createObjectStore("customers", { keyPath: "ssn" });

Transactions      objectStore.createIndex("name", "name", { unique: false });
                  objectStore.add({ ssn: "444-44-4444", name: "Bill", age: 35});



Cursors        var transaction = db.transaction(["customers"], IDBTransaction.READ_WRITE);




                     http://www.w3.org/TR/IndexedDB/
CouchDB
                     function(doc) {
                       if (doc.Type == "customer") {
                         emit(doc.LastName, {FirstName: doc.FirstName, Addr: doc.Address});
                         emit(doc.FirstName, {LastName: doc.LastName, Addr: doc.Address});

Views                }
                       }




JSON*                                {
                                         "total_rows":2,
                                         "offset":0,
                                         "rows":

Map / Reduce                             [
                                           {
                                             "id":"64ACF01B05F53ACFEC48C062A5D01D89",
                                             "key":"Katz",
                                             "value":{"FirstName":"Damien", "Addr":"Charlotte NC"}

Erlang alternative:                        },
                                           {
                                             "id":"64ACF01B05F53ACFEC48C062A5D01D89",
                                             "key":"Damien",

  Spidermonkey
                                             "value":{"LastName":"Katz", "Addr":"Charlotte NC"}
                                           },
                                         ]
                                     }



  Note: CouchDB moved from XML to JSON & JS in 2007*
                      http://wiki.apache.org/couchdb/HTTP_view_API
          * http://jan.prima.de/~jan/plok/archives/89-CouchDb-updates.html
CouchBase


CouchDB alternative
 using V8
 adding memcache
 meant to be more scalable


                http://www.couchbase.com/
MongoDB
                                      { text: "lmao! great article!",

Spidermonkey                          }
                                        author: 'kbanker',
                                        votes: 2




BSON                                        var map = function() {
                                               emit(this.author, {votes: this.votes});
                                            };

Map / Reduce
                                               // Add up all the votes for each key.

REST / JSON
                                               var reduce = function(key, values) {
                                                  var sum = 0;
                                                  values.forEach(function(doc) {
                                                    sum += doc.votes;
                                                  });

REST / JS                                      };
                                                  return {votes: sum};




Shell           var op = db.comments.mapReduce(map, reduce, {out: "mr_results"});




            http://www.mongodb.org/display/DOCS/MapReduce
Object
Persevere JavaScriptDB
                                                      var d = new Data();
                                                      d.test = 12345;




Rhino
                                                                {"id":"generated.js",
                                                                "sources":[
                                                                  {
                                                                    "name":"Data",
                                                                    "extends":"Object",
REST / JSON                                                         "schema":{
                                                                       "extends":{"$ref":"../Class/Object"},
                                                                       hello : function() {
                                                                          console.log("hello hi");
JSON Schema                                                            },
                                                                       "prototype":{
                                                                       }
                                                                     }
JSON Path                                                       }
                                                                  }]




JSON Query                                               curl localhost:8080/Data/1

                                                         ({"id":"1","test":12345})


                                                      Data.hello(); // INFO: hi there


   http://www.sitepen.com/blog/2009/04/20/javascriptdb-perseveres-new-high-performance-storage-engine/
WakandaDB

Webkit JavaScriptCore
REST / JSON
Data Classes
 auto-updatable
 accessors
               john = ds.Person.fid("fistName eq John");

 events        conferences = john.allConferences;

               JohnJSConferences = conferences.filter("title eq :1", "*JavaScript*");

 methods       JSAttendeesJohnMet = JSConferences.allPeople;


                      http://wakanda.org/
Multi-Model
ArangoDB


V8                   actions.defineHttp({
                       url : "world",
                       context : "api",

  events                callback : function (req, res) {
                          var collection = db._collection(req.parameter.collection);

                           if (collection == null) {

  filters                   }
                             ...

                           else {
                             ...
                           }

  transactions         }
                           actions.resultOk(req, res, actions.HTTP_OK, result);

                     });

Shell


                  http://www.ape-project.org/
OrientDB


rhino
                                                          // create function getAllCustomer
REST / JSON                                               return db.query("select from V")




transactions
                                                               db.begin();
                                                               try {

hooks (events)                                                 "
                                                               "
                                                                   // some code
                                                                   db.commit()
                                                               } catch (e) {
                                                               "   db.rollback();"
                                                               }

stored procedures
new com.orientechnologies.orient.core.record.impl.ODocument('Profile').field('name', 'Luca').save()



                                    http://www.orientdb.org/
reaching the DB
Reaching the DB

mongoose                      arango.client

mongodb-rhino                 WAF (Wakanda)

riak control                  Ext.data.proxy.Wakanda

backbone-couchdb              voltdb-client-nodejs

dojox.data.couchDBRestStore   redis-node-client

node-cassandra                orientdb-api.js
Thank you!



San Jose, CA - Oct. 26-27th     Paris, France - Nov. 16-17th

                         Join us at
                   JS.everywhere(2012)

Contenu connexe

Tendances

Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDBJames Williams
 
Core Data with multiple managed object contexts
Core Data with multiple managed object contextsCore Data with multiple managed object contexts
Core Data with multiple managed object contextsMatthew Morey
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring DataAnton Sulzhenko
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaScott Hernandez
 
Simplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaSimplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaMongoDB
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBTobias Trelle
 
Scalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDBScalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDBWilliam Candillon
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDBScott Hernandez
 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationDave Stokes
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Andy Bunce
 
Discover the Power of the NoSQL + SQL with MySQL
Discover the Power of the NoSQL + SQL with MySQLDiscover the Power of the NoSQL + SQL with MySQL
Discover the Power of the NoSQL + SQL with MySQLDave Stokes
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseDave Stokes
 
Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Tobias Trelle
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Hermann Hueck
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryWilliam Candillon
 
Squeak DBX
Squeak DBXSqueak DBX
Squeak DBXESUG
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOSMake School
 

Tendances (20)

Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDB
 
Core Data with multiple managed object contexts
Core Data with multiple managed object contextsCore Data with multiple managed object contexts
Core Data with multiple managed object contexts
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
 
OrientDB
OrientDBOrientDB
OrientDB
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
Simplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaSimplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with Morphia
 
Bonjour, iCloud
Bonjour, iCloudBonjour, iCloud
Bonjour, iCloud
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
Scalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDBScalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDB
 
Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentation
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
 
Discover the Power of the NoSQL + SQL with MySQL
Discover the Power of the NoSQL + SQL with MySQLDiscover the Power of the NoSQL + SQL with MySQL
Discover the Power of the NoSQL + SQL with MySQL
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational Database
 
Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
 
Squeak DBX
Squeak DBXSqueak DBX
Squeak DBX
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOS
 

Similaire à JavaScript & NoSQL: A Love Story

Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Ayes Chinmay
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Zianed Hou
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsAlexander Rubin
 
Entity Framework Core & Micro-Orms with Asp.Net Core
Entity Framework Core & Micro-Orms with Asp.Net CoreEntity Framework Core & Micro-Orms with Asp.Net Core
Entity Framework Core & Micro-Orms with Asp.Net CoreStephane Belkheraz
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsMichael Lehmann
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii명철 강
 
Apache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster ComputingApache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster ComputingGerger
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...Inhacking
 
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Аліна Шепшелей
 

Similaire à JavaScript & NoSQL: A Love Story (20)

Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
 
Lecture17
Lecture17Lecture17
Lecture17
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 
Mobile Web 5.0
Mobile Web 5.0Mobile Web 5.0
Mobile Web 5.0
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
Entity Framework Core & Micro-Orms with Asp.Net Core
Entity Framework Core & Micro-Orms with Asp.Net CoreEntity Framework Core & Micro-Orms with Asp.Net Core
Entity Framework Core & Micro-Orms with Asp.Net Core
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Jdbc
JdbcJdbc
Jdbc
 
XQuery Rocks
XQuery RocksXQuery Rocks
XQuery Rocks
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
Dropwizard
DropwizardDropwizard
Dropwizard
 
3 database-jdbc(1)
3 database-jdbc(1)3 database-jdbc(1)
3 database-jdbc(1)
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Spring data iii
Spring data iiiSpring data iii
Spring data iii
 
Apache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster ComputingApache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster Computing
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
 
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
 

Plus de Alexandre Morgaut

Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...Alexandre Morgaut
 
Past, present, and future of web assembly - Devfest Nantes 2017
Past, present, and future of web assembly - Devfest Nantes 2017Past, present, and future of web assembly - Devfest Nantes 2017
Past, present, and future of web assembly - Devfest Nantes 2017Alexandre Morgaut
 
angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42Alexandre Morgaut
 
Carnet de Route du Développeur - ENSIMAG 2012
Carnet de Route du Développeur - ENSIMAG 2012Carnet de Route du Développeur - ENSIMAG 2012
Carnet de Route du Développeur - ENSIMAG 2012Alexandre Morgaut
 
Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014
Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014
Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014Alexandre Morgaut
 
HTML5 in automotive - web2day 2014
HTML5 in automotive  - web2day 2014HTML5 in automotive  - web2day 2014
HTML5 in automotive - web2day 2014Alexandre Morgaut
 
JS in SMS - JS.everywhere(2013)
JS in SMS - JS.everywhere(2013)JS in SMS - JS.everywhere(2013)
JS in SMS - JS.everywhere(2013)Alexandre Morgaut
 
Js in Automotive - JS.everywhere(2013)
Js in Automotive - JS.everywhere(2013)Js in Automotive - JS.everywhere(2013)
Js in Automotive - JS.everywhere(2013)Alexandre Morgaut
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013Alexandre Morgaut
 
From Web App Model Design to Production with Wakanda
From Web App Model Design to Production with WakandaFrom Web App Model Design to Production with Wakanda
From Web App Model Design to Production with WakandaAlexandre Morgaut
 
Wakanda - apps.berlin.js - 2012-11-29
Wakanda - apps.berlin.js - 2012-11-29Wakanda - apps.berlin.js - 2012-11-29
Wakanda - apps.berlin.js - 2012-11-29Alexandre Morgaut
 
End to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeEnd to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeAlexandre Morgaut
 
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) EuropeWakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) EuropeAlexandre Morgaut
 
End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012Alexandre Morgaut
 
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012Alexandre Morgaut
 
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012Alexandre Morgaut
 
Etat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS GeneveEtat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS GeneveAlexandre Morgaut
 
NantesJS premier meetup - Welcome
NantesJS premier meetup - WelcomeNantesJS premier meetup - Welcome
NantesJS premier meetup - WelcomeAlexandre Morgaut
 
State of the art: server-side javaScript - NantesJS
State of the art: server-side javaScript - NantesJSState of the art: server-side javaScript - NantesJS
State of the art: server-side javaScript - NantesJSAlexandre Morgaut
 

Plus de Alexandre Morgaut (20)

Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
 
Past, present, and future of web assembly - Devfest Nantes 2017
Past, present, and future of web assembly - Devfest Nantes 2017Past, present, and future of web assembly - Devfest Nantes 2017
Past, present, and future of web assembly - Devfest Nantes 2017
 
angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42
 
Carnet de Route du Développeur - ENSIMAG 2012
Carnet de Route du Développeur - ENSIMAG 2012Carnet de Route du Développeur - ENSIMAG 2012
Carnet de Route du Développeur - ENSIMAG 2012
 
Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014
Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014
Conquer Architectural Challenges with End-to-End JavaScript - enterJS 2014
 
HTML5 in automotive - web2day 2014
HTML5 in automotive  - web2day 2014HTML5 in automotive  - web2day 2014
HTML5 in automotive - web2day 2014
 
JS in SMS - JS.everywhere(2013)
JS in SMS - JS.everywhere(2013)JS in SMS - JS.everywhere(2013)
JS in SMS - JS.everywhere(2013)
 
Js in Automotive - JS.everywhere(2013)
Js in Automotive - JS.everywhere(2013)Js in Automotive - JS.everywhere(2013)
Js in Automotive - JS.everywhere(2013)
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
From Web App Model Design to Production with Wakanda
From Web App Model Design to Production with WakandaFrom Web App Model Design to Production with Wakanda
From Web App Model Design to Production with Wakanda
 
Wakanda - apps.berlin.js - 2012-11-29
Wakanda - apps.berlin.js - 2012-11-29Wakanda - apps.berlin.js - 2012-11-29
Wakanda - apps.berlin.js - 2012-11-29
 
End to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeEnd to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) Europe
 
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) EuropeWakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
 
End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012
 
End-to-end W3C APIs
End-to-end W3C APIsEnd-to-end W3C APIs
End-to-end W3C APIs
 
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
 
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
 
Etat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS GeneveEtat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS Geneve
 
NantesJS premier meetup - Welcome
NantesJS premier meetup - WelcomeNantesJS premier meetup - Welcome
NantesJS premier meetup - Welcome
 
State of the art: server-side javaScript - NantesJS
State of the art: server-side javaScript - NantesJSState of the art: server-side javaScript - NantesJS
State of the art: server-side javaScript - NantesJS
 

Dernier

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Dernier (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

JavaScript & NoSQL: A Love Story

  • 1. JavaScript & NoSQL a Love Story! by Alexandre Morgaut NoSQL matters - Barcelona 2012
  • 2. Presentation W3C AC member Web Architect JS Expert REST Lover NoSQL Fanboy @amorgaut
  • 4. NoSQL Facts Mostly Schemaless Often with REST / JSON API Many store JSON Many embed a JavaScript engine Map / Reduce events Many propose a JavaScript Shell
  • 6. JavaScript Facts Created in 1995 Running in Netscape Server in 1996, and then in IIS Mostly Event-Driven Recommended in the REST definition in 2000 Integrated in CouchDB in 2007 HTML5 Datastores appeared in 2009
  • 8. JavaScript & Databases Netscape Enterprise Server Microsoft: JScript, JScript.NET, ActiveX Mozilla Rhino JSDB APE Project W3C Web SQL
  • 9. Netscape Enterprise Server SQLTable() pool = new DbPool("ORACLE", addr, user, pwd, "", 5, true); connection = pool.connection("A connection"); cursor = connection.cursor("select name from customer"); DbPool if ( cursor && (connection.majorErrorCode() == 0) ) { // Get the first row cursor.next(); start/home.html // Display the values write("<B>Customer Name:</B> " + cursor.name + "<BR>"); //Close the cursor cursor.close(); } Shared Connections Note: Netscape Enterprise Server merged with Javagator to become iPlanet
  • 10. MS JScript on the server conn = Server.CreateObject("ADODB.Connection"); Active Server Page conn.Open(dsn, login, password); reccordset = conn.Execute(sqlQuery); result = []; runat=”server” while (!reccordset.EOF) { result.push({ Windows Script Hosting field1: reccordset("field1"), field2: reccordset("field2") }); rsAuthor2.MoveNext; .NET } conn.Close(); conn = null; Note: JScript is running on Microsoft IIS since 1997
  • 11. MS JScript in the Browser var connection = new ActiveXObject("ADODB.Connection");    connection.Open(dsn, login, password); ActiveXObject var reccordset = new ActiveXObject("ADODB.Recordset");   reccordset.Open(sqlQuery, connection); reccordset.MoveFirst; only IE while(!reccordset.eof) { document.write(reccordset.fields(1)); reccordset.movenext; }   reccordset.close; connection.close;
  • 12. Mozilla Rhino importPackage(java.sql); java.lang.Class.forName("org.sqlite.JDBC"); Java environment conn = DriverManager.getConnection("jdbc:sqlite:test.db"); stat = conn.createStatement(); resultSet = stat.executeQuery("select * from people;"); Access to JDBC while (resultSet.next()){ print( resultSet.getString("name") + " - " + ex: RingoJS resultSet.getString("occupation") ); } resultSet.close(); stat.close(); conn.close(); https://developer.mozilla.org/en-US/docs/Rhino
  • 13. JSDB var db = new ODBC(dsn); var result = db.query("select * from mytable"); SpiderMonkey var searcher = new Index; for (var i=1; i <= result.count; i++) { searcher.add(result.get('NAME')); Shell } var i = searcher.find('Mr. Smith'); var r = result.getRow(i + 1); JS Server writeln('Data for Mr. Smith'); writeln(r.toString()); db.close(); http://www.jsdb.org/
  • 14. APE Project var sql = new Ape.MySQL(ip + ":3306", user, password, db); Ape.registerCmd('foo', true, function(params, cmd) { Real Time Web cmd.user.sendRaw( 'bar', { hello: 'world', Comet ); } echo: params.ping sql.query( Web Sockets 'INSERT INTO table(log) VALUES("' + Ape.MySQL.escape(params.ping) + '")', function(res, errorNo) { MySQL Ape.log('Inserted ' + this.getInsertId()); } ); }); Note: APE means “Ajax Push Engine” http://www.ape-project.org/
  • 15. W3C Web SQL HTML5 var db = openDatabase('mydb', '1.0', 'my first db', 2 * 1024 * 1024); Safari db.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)'); tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "synergies")'); }); Chrome tx.executeSql('SELECT * FROM foo', [], function (tx, results) { for (var i = 0, len = results.rows.length; i < len; i++) { alert(results.rows.item(i).text); Opera } }); Sync / Async result = x.executeSqlSync('SELECT * FROM foo'); for (var i = 0, len = results.rows.length; i < len; i++) { alert(results.rows.item(i).text); } Note: standard paused because current implementations are only based on SQLite http://html5doctor.com/introducing-web-sql-databases/
  • 19. Touching the DB Heart Key-Value: Web Storage, Riak Document: CouchDB, MongoDB, IndexedDB Object: JavaScriptDB, WakandaDB Multi-Model: OrientDB & ArangoDB
  • 21. Web Storage W3C / WHATWG // set or get items by methods localStorage.setItem("storedItem", "value"); var value = localStorage.getItem("storedItem"); HTML5 // set or get items using the store as a map localStorage.storedItem = value; var value = localStorage.storedItem; local // accessible only for this session var foo = sessionStorage.bar; session sessionStorage.bar = foo; // sync interface when data change, even from other window window.addEventListener("storage", handle_storage, false); events Note: Firefox also implement “globalStorage”, and Wakanda “user.storage” http://www.w3.org/TR/webstorage/
  • 22. Riak {"inputs": "goog", Buckets "query": [ {"map": {"language": "javascript", "source": "function(value, keyData, arg){...}" }}, REST / JSON {"reduce": {"language": "javascript", "source": "function(values, arg){...}", "keep": true }} ] Map / Reduce } // Map: compute the daily variance, key it by the month Erlang alternative: function(value, keyData, arg){ var data = Riak.mapValuesJson(value)[0]; var month = value.key.split('-').slice(0,2).join('-'); var obj = {}; obj[month] = data.High - data.Low; SpiderMonkey } return [ obj ]; // Reduce: find the maximum variance per month function(values, arg) { return [values.reduce(function(acc, item){ for (var month in item) { acc[month] = acc[month] ? Math.max(item[month], acc[month]) : item[month]; } return acc; })]; } http://wiki.basho.com/MapReduce-Implementation.html
  • 24. IndexedDB var request = indexedDB.open("MyTestDatabase", 3); W3C / WHATWG request.onerror = function(event) { HTML5 // Do something with request.errorCode! }; request.onsuccess = function(event) { // Do something with request.result! }; Sync / Async request.onupgradeneeded = function(event) { // Update object stores and indices .... Indexes } var objectStore = db.createObjectStore("customers", { keyPath: "ssn" }); Transactions objectStore.createIndex("name", "name", { unique: false }); objectStore.add({ ssn: "444-44-4444", name: "Bill", age: 35}); Cursors var transaction = db.transaction(["customers"], IDBTransaction.READ_WRITE); http://www.w3.org/TR/IndexedDB/
  • 25. CouchDB function(doc) { if (doc.Type == "customer") { emit(doc.LastName, {FirstName: doc.FirstName, Addr: doc.Address}); emit(doc.FirstName, {LastName: doc.LastName, Addr: doc.Address}); Views } } JSON* { "total_rows":2, "offset":0, "rows": Map / Reduce [ { "id":"64ACF01B05F53ACFEC48C062A5D01D89", "key":"Katz", "value":{"FirstName":"Damien", "Addr":"Charlotte NC"} Erlang alternative: }, { "id":"64ACF01B05F53ACFEC48C062A5D01D89", "key":"Damien", Spidermonkey "value":{"LastName":"Katz", "Addr":"Charlotte NC"} }, ] } Note: CouchDB moved from XML to JSON & JS in 2007* http://wiki.apache.org/couchdb/HTTP_view_API * http://jan.prima.de/~jan/plok/archives/89-CouchDb-updates.html
  • 26. CouchBase CouchDB alternative using V8 adding memcache meant to be more scalable http://www.couchbase.com/
  • 27. MongoDB { text: "lmao! great article!", Spidermonkey } author: 'kbanker', votes: 2 BSON var map = function() { emit(this.author, {votes: this.votes}); }; Map / Reduce // Add up all the votes for each key. REST / JSON var reduce = function(key, values) { var sum = 0; values.forEach(function(doc) { sum += doc.votes; }); REST / JS }; return {votes: sum}; Shell var op = db.comments.mapReduce(map, reduce, {out: "mr_results"}); http://www.mongodb.org/display/DOCS/MapReduce
  • 29. Persevere JavaScriptDB var d = new Data(); d.test = 12345; Rhino {"id":"generated.js", "sources":[ { "name":"Data", "extends":"Object", REST / JSON "schema":{ "extends":{"$ref":"../Class/Object"}, hello : function() { console.log("hello hi"); JSON Schema }, "prototype":{ } } JSON Path } }] JSON Query curl localhost:8080/Data/1 ({"id":"1","test":12345}) Data.hello(); // INFO: hi there http://www.sitepen.com/blog/2009/04/20/javascriptdb-perseveres-new-high-performance-storage-engine/
  • 30. WakandaDB Webkit JavaScriptCore REST / JSON Data Classes auto-updatable accessors john = ds.Person.fid("fistName eq John"); events conferences = john.allConferences; JohnJSConferences = conferences.filter("title eq :1", "*JavaScript*"); methods JSAttendeesJohnMet = JSConferences.allPeople; http://wakanda.org/
  • 32. ArangoDB V8 actions.defineHttp({ url : "world", context : "api", events callback : function (req, res) { var collection = db._collection(req.parameter.collection); if (collection == null) { filters } ... else { ... } transactions } actions.resultOk(req, res, actions.HTTP_OK, result); }); Shell http://www.ape-project.org/
  • 33. OrientDB rhino // create function getAllCustomer REST / JSON return db.query("select from V") transactions db.begin(); try { hooks (events) " " // some code db.commit() } catch (e) { " db.rollback();" } stored procedures new com.orientechnologies.orient.core.record.impl.ODocument('Profile').field('name', 'Luca').save() http://www.orientdb.org/
  • 35. Reaching the DB mongoose arango.client mongodb-rhino WAF (Wakanda) riak control Ext.data.proxy.Wakanda backbone-couchdb voltdb-client-nodejs dojox.data.couchDBRestStore redis-node-client node-cassandra orientdb-api.js
  • 36. Thank you! San Jose, CA - Oct. 26-27th Paris, France - Nov. 16-17th Join us at JS.everywhere(2012)