JSON Evaluation. User Store

Similar documents
MongoDB. CSC309 TA: Sukwon Oh

However, they are limited tools for developing APIs

Advanced Database Project: Document Stores and MongoDB

CS193X: Web Programming Fundamentals

What is Node.js? Tim Davis Director, The Turtle Partnership Ltd

Extra Notes - Data Stores & APIs - using MongoDB and native driver

Callbacks & Promises

JavaScript Lecture 1

NODE.JS MOCK TEST NODE.JS MOCK TEST I

Laszlo SZATHMARY University of Debrecen Faculty of Informatics

Node.js. Node.js Overview. CS144: Web Applications

Databases/JQuery AUGUST 1, 2018

MEAN Stack. 1. Introduction. 2. Foundation a. The Node.js framework b. Installing Node.js c. Using Node.js to execute scripts

Online Multimedia Winter semester 2015/16

ITG Software Engineering

Catbook Workshop: Intro to NodeJS. Monde Duinkharjav

relational Key-value Graph Object Document

Kyle Rainville Littleton Coin Company

Practical Node.js. Building Real-World Scalable Web Apps. Apress* Azat Mardan

Index. findall(), 368 findbyid(), 363 findone(), 364 invocations and code sections, 383 removing documents, 379 updatefirst(), 373 updatemulti(), 376

Frontend UI Training. Whats App :

Express.JS. Prof. Cesare Pautasso Modularity

MongoDB. Database Initialization. Note

JS Event Loop, Promises, Async Await etc. Slava Kim

[301] JSON. Tyler Caraza-Harter

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

Running and Debugging Custom Components Locally

Smashing Node.JS: JavaScript Everywhere

webpack bundle inner structure and optimization Alexey Ivanov, Evil Martians

JavaScript Rd2. -Kyle Simpson, You Don t Know JS

MongoDB. Robert M. Vunabandi

Full Stack boot camp

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

CRM Service Wrapper User Guide

Topic 12: Connecting Express and Mongo

5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414

Database Systems CSE 414

A RESTFUL API WITH MONGODB. A Project. California State University, Sacramento

Web Application Development

5th April Installation Manual. Department of Computing and Networking Software Development Degree

User & Candidate APIs

MEAN February. techdt.la

Creating a modern web application using Symfony API Platform, ReactJS and Redux. by Jesus Manuel Olivas &

Contact center integration with CRM. White paper and best practice for Daktela V6 setup with internal CRM system

Today: Distributed Middleware. Middleware

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. GraphQL

IN Development in Platform Ecosystems Lecture 3: json, ajax, APIs

JSON as an XML Alternative. JSON is a light-weight alternative to XML for datainterchange

Getting Started with IBM Bluemix Hands-On Workshop. Module 6a: Services

Microservices with Node.js

Node.js 8 the Right Way

CSC Web Technologies, Spring Web Data Exchange Formats

Sterling Survey System

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

Flat triples approach to RDF graphs in JSON

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

Quick Desktop Application Development Using Electron

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

NOSQL EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY

Web Scraping XML/JSON. Ben McCamish

Getting Mean. Practical Perspective. Prof. Dr. Alejandro Zunino, Prof. Dr. Alfredo Teyseyre. ISISTAN Department of Computer Science UNICEN

asphalt-py4j Release post1

Document Object Storage with MongoDB

Ninox API. Ninox API Page 1 of 15. Ninox Version Document version 1.0.0

Introduction to Azure DocumentDB. Jeff Renz, BI Architect RevGen Partners

A Package Manager for Curry

Product: DQ Order Manager Release Notes

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

Hands on Angular Framework

Tuesday, January 13, Backend III: Node.js with Databases

CSC Web Programming. Introduction to JavaScript

Data Collections. Welcome to the Fourth Dimension (and beyond) Martin Phillips Ladybridge Systems Ltd. International Spectrum Conference, 2014

Human-Computer Interaction Design

In addition to the primary macro syntax, the system also supports several special macro types:

MongoDB Tutorial for Beginners

donation-service-test

Automate with Grunt. Extracted from: The Build Tool for JavaScript. The Pragmatic Bookshelf

CSE 344 APRIL 16 TH SEMI-STRUCTURED DATA

Web Development for Dinosaurs An Introduction to Modern Web Development

MarkLogic Server. Node.js Application Developer s Guide. MarkLogic 8 February, Copyright 2016 MarkLogic Corporation. All rights reserved.

Course Content MongoDB

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

This tutorial covers most of the topics required for a basic understanding of EmberJS and to get a feel of how it works.

NoSQL & Firebase. SWE 432, Fall Web Application Development

Getting started with Tabris.js Tutorial Ebook

Distributed Systems 8. Remote Procedure Calls

Reactive Web Programming

LECTURE 02 INTRODUCTION TO C++

Guides SDL Server Documentation Document current as of 05/24/ :13 PM.

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Comprehensive AngularJS Programming (5 Days)

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com

Salvatore Rinzivillo VISUAL ANALYTICS

SSJS Server-Side JavaScript WAF Wakanda Ajax Framework

MarkLogic Server. Node.js Application Developer s Guide. MarkLogic 9 May, Copyright 2017 MarkLogic Corporation. All rights reserved.

Brunch Documentation. Release Brunch team

Lecture 8 (7.5?): Javascript

MarkLogic Server. Entity Services Developer s Guide. MarkLogic 9 May, Copyright 2018 MarkLogic Corporation. All rights reserved.

nucleon Documentation

ACT-R WS JSON Network Interface (JNI) to ACT-R Interfacing ACT-R with External Environments. Rensselaer Cognitive. Mike Schoelles and Ryan Hope

Transcription:

Overview Demo following technologies: JSON Node Package Manager npm Node modules. Very brief introduction to asynchronous programming using async and await. Mongo db

JSON JavaScript Object Notation. Inductive denition for JSON values: Primitives null, true, false, numbers and "-quoted strings. Minimal set of escape sequences in strings. Sequences Comma-separated JSON values within [ ]. Maps Comma-separated key-value pairs within { }. Keys must be JSON strings and values are JSON values. Though JSON bears a supercial resemblance to JavaScript object literals, it is a dierent notation. Example

JSON Evaluation Widely popular for transferring structured data between heterogeneous systems. Preferred over XML for structured data (XML is good for structured documents). Not suitable as a conguration format as no comments allowed. (YAML is a better format). In JavaScript, built-in JSON object provides stringify() and parse() methods to convert JavaScript objects to / from a string. Some JSON libraries allow comments (and other features like terminating commas) as syntax extensions, but not as per JSON standard.

Node Package Manager Manages dependencies between packages or modules. Local packages: dependencies of your project. Global packages: use for CLI tools. package.json describes project dependencies and package-lock.json serves to lock-down dependency versions. By default, packages are installed in node_modules directory of current directory. Usually package.json and package-lock.json are checked into version control but not the node_modules directory. To run a project after checking it out from version control it is usually enough to simply run npm install

Semantic Versioning Semantic Versioning attempts to avoid dependency hell. It uses a 3 part version number: M.m.r where each part is a integer without leading zeros. Revision Number r Incremented for bug xes. Minor Version m Incremented for added functionality which is backward compatible. Major Version M Incremented for incompatible changes which are not backward compatible.

Node Modules Modules provide encapsulation; Entities like variables, functions, classes are inaccessible outside a module unless explicitly exported by the module. A nodejs module is either a JavaScript le, or a directory with either a package.json or index.js le in it. A le can export information by assigning to module.exports. The value which is assigned can be any JavaScript value; common values exported are either a single function or class, or a JavaScript object mapping names to JavaScript entities. When a module is require'd, the return value of the require() is simply the value which was assigned to module.exports.

Examples of Using require() Assume./myModule.js exports using function f() {... } class C {... } const VAL =...; module.exports = { f: f, C: C, VAL: VAL }; We can require entire module using: const mymodule = require('./mymodule'); //code can use mymodule.f, mymodule.c, mymodule.val We can require only part of exports using destructuring: const { VAL: myval } = require('./mymodule');

Require Paths If a module is required using a relative or absolute path, then the folder or le at that path is loaded (trying extensions.js or.json). If a module is required without specifying a path, then it is looked for in the user's directory starting with the current directory as well as in global installation directories. > module.paths [ '/home/umrigar/tmp/repl/node_modules', '/home/umrigar/tmp/node_modules', '/home/umrigar/node_modules', '/home/node_modules', '/node_modules', '/home/umrigar/.node_modules', '/home/umrigar/.node_libraries', '/usr/lib/nodejs' ] >

MongoDb One of many nosql databases. No rigid relations need to be predened. Allows storing and querying json documents. Provides basic Create-Read-Update-Delete (CRUD) repertoire.

Mongo Crud Create insertone() and insertmany(). Read find() returns a Cursor. Can grab all using toarray(). Update updateone() and updatemany(). Also, findoneandupdate() and findoneandreplace(). Delete deleteone() and deletemany(). All functions require a callback, but will return a Promise if called without a callback.

Features Store user-info objects. No schema for user-info objects, except that each object must have a id property. Have id property default to email set in global git conguration for current user. Basic CRUD functionality.

Log $./index.js read lisa NOT_FOUND: user(s) {"id":"lisa"} not found $./index.js create simpsons.json $./index.js create simpsons.json EXISTS: user(s) bart, marge, lisa, homer already exist

Log Continued $./index.js read homer lisa [ { "id": "homer", "firstname": "Homer", "lastname": "Simpson", "email": "chunkylover53@aol.com" }, { "id": "lisa", "firstname": "Lisa", "lastname": "Simpson", "birthdate": "1982-05-09", "email": "smartgirl63_\\@yahoo.com" } ]

Log Continued $./index.js delete lisa $./index.js read lisa NOT_FOUND: user(s) {"id":"lisa"} not found $./index.js update homer birthdate=1953-03-31 $./index.js read homer [ { "id": "homer", "firstname": "Homer", "lastname": "Simpson", "email": "chunkylover53@aol.com", "birthdate": "1953-03-31" } ]

Log Continued $./index.js create #default id set to git email $./index.js read umrigar@binghamton.edu [ { "id": "umrigar@binghamton.edu" } ] $./index.js update umrigar@binghamton.edu \ name='zerksis umrigar' $./index.js read umrigar@binghamton.edu [ { "id": "umrigar@binghamton.edu", "name": "zerksis umrigar" } ] $

Initializing Project $ npm init -y... $ npm install --save mongodb npm notice created a lockfile as package-lock.json...... added 6 packages in 6.074s $ ls -a....gitignore node_modules package.json package-lock.json $

async and await Friendlier syntax layered over more basic asynchronous facilities. Allows calling asynchronous functions in a synchronous style. Declare asynchronous functions using the async keyword. Call asynchronous functions using the await keyword. await is recognized only within the body of a function which has been declared async. async / await is a new addition to JavaScript. Older nodejs API's need to be promisied using util.promisify().

Implementation index.js Wrapper which dispatches to command-line handling. user-store-cli.js Command-line handling. user-store.js Implementation of db operations.

Mongo Shell Log Allows interacting with mongo db. Following log assumes that collection userinfos in db users is loaded with simpsons data. $ mongo MongoDB shell version: 3.2.11... > use users switched to db users > db.userinfos.find({}) { "_id" : "bart", "id" : "bart",... } { "_id" : "marge", "id" : "marge",... } { "_id" : "lisa", "id" : "lisa",... } { "_id" : "homer", "id" : "homer",... } > db.userinfos.find({"firstname": "Bart"}) { "_id" : "bart", "id" : "bart",... } > db.userinfos.find({}).length() 4

Mongo Shell Log Continued > db.userinfos.remove({"firstname": "Bart"}) WriteResult({ "nremoved" : 1 }) > db.userinfos.find({}).length() 3 > db.userinfos.remove({}) WriteResult({ "nremoved" : 3 }) > db.userinfos.find({}).length() 0