SlideShare uma empresa Scribd logo
1 de 43
Will Button - @wfbutton
Practical MongoDB
From template to
production
Many resources exist for individual components.
Getting them to work together is a different story.
{
name: ‘Will Button’,
contact: [twitter: ‘@wfbutton’, email: ‘willb@mylist.com’, web: ‘www.two4seven.me’],
role: [‘dev’, ‘ops’, ‘it’],
company: ‘myList.com’
}
mean stack
facebook
passport.js
d3.js
The problem.
Participants competing in a challenge log meals, workouts and health data into a private Facebook group
Facebook newsfeed algorithm
No reporting
Don’t want to lose demographics
Can we use existing frameworks to make it
better without losing the parts that work well?
The solution.
Tools and
Technologies
Practical
Application
Step 1: MEAN Stack
Template
git clone http://github.com/linnovate/mean.git
Connecting Facebook…
https://developers.facebook.com/apps
Configure passport
Facebook Permissions
Default: profile, friends list, email
Can’t read newsfeed by default
Reading newsfeed requires valid
accessToken
Facebook Permissions
https://developers.facebook.com/docs/faceboo
k-login/permissions/
What about this
accessToken thing?
> db.users.findOne({ provider: "facebook" })
{
"__v" : 0,
"_id" : ObjectId("52f6fc252ae38687577cc688"),
"currentchallenge" : ObjectId("5308d9756d7d30a94b681b2d"),
"email" : "will@paleotracking.com",
"facebook" : {
"username" : "will.button.56",
"updated_time" : "2014-01-06T22:33:03+0000",
"verified" : true,
"locale" : "en_US",
"timezone" : -7,
"email" : "wfbutton@gmail.com",
"gender" : "male",
"education" : [
{ "type" : "High School", "school" : { "name" : "Sidney High School", "id" : "110094965686846" } }
],
"favorite_athletes" : [
{ "name" : "CrossFit Endurance", "id" : "182015510972" },
{ "name" : "Lucas Parker", "id" : "346667935460586" }
],
"favorite_teams" : [
{ "name" : "Dallas Cowboys", "id" : "99559607813" }
],
"work" : [
{ "start_date" : "0000-00", "employer" : { "name" : "myList", "id" : "105017792957809" } },
{ "end_date" : "0000-00", "start_date" : "2004-07-01", "employer" : { "name" : "NightHawk Radiology Services", "id" :
"115173631830635" } }
],
"bio" : "CrossFit Level 1 (CF-L1) Trainer",
"location" : { "name" : "Jost Van Dyke, British Virgin Islands", "id" : "327610993996350" },
"hometown" : { "name" : "Sidney, Texas", "id" : "108011082555210" },
"link" : "https://www.facebook.com/will.button.56",
"last_name" : "Button",
"first_name" : "Will",
"name" : "Will Button",
"id" : "100001902024344"
},
"name" : "Will Button",
"provider" : "facebook",
"username" : "will.button.56"
All of this for FREE
$$$$
But no accessToken

Passport.js
Refreshes oauth
accessToken
on login
YIKES!
Functional, but
not scalable.
User.js Model
Updated user.js
model to store
accessToken
Using Facebook OpenGraph
Displaying Entries
Stored Documents
{
"user" :
ObjectId("52f6fc252ae38687577cc688"),
"message" : "I ate my stuff",
"challenge" :
ObjectId("5302e4e445bae1611e2e60d9"),
"_id" :
ObjectId("53125a106184fe00006e46d6"),
"likes" : {
"data" : [ ]
},
"comments" : {
"data" : [ ]
},
"updated_time" : ISODate("2014-03-
01T22:07:12.442Z"),
"created_time" : ISODate("2014-03-
01T22:07:12.442Z"),
"__v" : 0
Journal Data Model
var JournalSchema = new Schema({
created_time: {
type: Date,
default: Date.now
},
updated_time: {
type: Date,
default: Date.now
},
message: {
type: String
},
comments: {
data: [CommentSchema]
},
likes: {
data: [LikesSchema]
},
user: {
type: Schema.ObjectId,
ref: 'User'
},
challenge: {
type: Schema.ObjectId,
ref: 'Challenge'
}
});
var LikesSchema = new Schema({
id: {
type: String
},
name: {
type: String
}
});
Controller (part of it anyway)
All accessible via Routes
Recap: Where are we now?
Reporting
Aggregation Framework
Aggregation : Quick Review
Pipeline for multiple stages of document transformations for producing aggregated results
Name Description
$project Reshapes a document stream. $project can rename, add, or remove fields as well as create
computed values and sub-documents.
$match Filters the document stream, and only allows matching documents to pass into the next
pipeline stage. $match uses standard MongoDB queries.
$limit Restricts the number of documents in an aggregation pipeline.
$skip Skips over a specified number of documents from the pipeline and returns the rest.
$unwind Takes an array of documents and returns them as a stream of documents.
$group Groups documents together for the purpose of calculating aggregate values based on a
collection of documents.
$sort Takes all input documents and returns them in a stream of sorted documents.
$geoNear Returns an ordered stream of documents based on proximity to a geospatial point.
db.journals.aggregate(
{ $group:
{ _id: "$from.name", numposts: { $sum: 1 } }
},
{ $project:
{ who: "$from.name", numposts: 1 } },
{ $sort:
{_id: 1 }
}
)
{
"result" : [
{
"_id" : "Andrew",
"numposts" : 83
},
{
"_id" : "Ben",
"numposts" : 108
},
########### results truncated for brevity ##########
{
"_id" : "Tara",
"numposts" : 20
},
{
"_id" : "Will",
"numposts" : 26
}
],
"ok" : 1
}
Accessible via:
http://localhost:3000/journals/ppu
Page is
rendered By a
controller
With a
directive
Using D3
injected as a
service
The Controller
angular.module('mean.reports').controller('ReportsController', ['$scope', '$http', function($scope, $http){
$http({
method: 'GET',
url: '/journals/ppu'
}).then(function(data, status) {
$scope.d3Data = data.data;
});
}]);
d3Bars Directive
this
gets normalized to
d3Bars Directive
D3 library injected as
a service
The d3 service is accessible
because we add the service to our
footer
And inject it as a
dependency
The service itself simply
downloads d3.js
Directives are just reusable pieces of code
Restrict where the
directive can be used
A/E/C
Scope refers to the type of isolated scope:
=  two way data binding with the parent DOM object
@  one way data binding with the parent DOM object
&  expression binding with the parent DOM object
link is basically
a controller
variables either specified
on declaration or use
defaults
Where do we go from here?
Where do we go from here?
Add new
aggregation queries
to journals controller
Build new reports/d3
visualizations in
directives.js
Add directives to any page:
<d3-bars data="d3Data”></d3-bars>
The mistakes people I
make.
Request the right
Facebook
permissions
Setup your
Facebook
Developers Account
Make your Facebook app
public (at least for a few
minutes)
Facebook Graph
Explorer
Hardcode dummy
data first.
Don’t assume
.success(), wait for it
.then()
Do
this
now:
• Clone the MEAN stack
• Stub out dummy data
• Build a d3 graph
• Stick around
www.two4seven.me/dcc
@wfbutton

Mais conteúdo relacionado

Mais procurados

Conquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQLConquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQLInes Panker
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETJames Johnson
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coveragecoldfascism4997
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationMongoDB
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coveragecreepypreview6376
 
Health News & Articles | Healthy Living
Health News & Articles | Healthy LivingHealth News & Articles | Healthy Living
Health News & Articles | Healthy Livingabortivecatcall84
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coveragealertchair8725
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC Newsboorishvictim1493
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC Newsignorantlogic4950
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScriptMark Casias
 
A single language for backend and frontend from AngularJS to cloud with Clau...
A single language for backend and frontend  from AngularJS to cloud with Clau...A single language for backend and frontend  from AngularJS to cloud with Clau...
A single language for backend and frontend from AngularJS to cloud with Clau...Walter Dal Mut
 
What Would You Do? With John Quinones
What Would You Do? With John QuinonesWhat Would You Do? With John Quinones
What Would You Do? With John Quinonesmoaninglunatic320
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC Newswaggishwedge3973
 
Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5johnwilander
 
Getting Started with MongoDB: 4 Application Designs
Getting Started with MongoDB: 4 Application DesignsGetting Started with MongoDB: 4 Application Designs
Getting Started with MongoDB: 4 Application DesignsDATAVERSITY
 
Dream House Project Presentation
Dream House Project PresentationDream House Project Presentation
Dream House Project Presentationjongosling
 

Mais procurados (20)

Conquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQLConquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQL
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coverage
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
 
Web scripts for practice
Web scripts for practiceWeb scripts for practice
Web scripts for practice
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coverage
 
Health News & Articles | Healthy Living
Health News & Articles | Healthy LivingHealth News & Articles | Healthy Living
Health News & Articles | Healthy Living
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coverage
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScript
 
U.S. News | National News
U.S. News | National NewsU.S. News | National News
U.S. News | National News
 
A single language for backend and frontend from AngularJS to cloud with Clau...
A single language for backend and frontend  from AngularJS to cloud with Clau...A single language for backend and frontend  from AngularJS to cloud with Clau...
A single language for backend and frontend from AngularJS to cloud with Clau...
 
What Would You Do? With John Quinones
What Would You Do? With John QuinonesWhat Would You Do? With John Quinones
What Would You Do? With John Quinones
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5
 
Getting Started with MongoDB: 4 Application Designs
Getting Started with MongoDB: 4 Application DesignsGetting Started with MongoDB: 4 Application Designs
Getting Started with MongoDB: 4 Application Designs
 
Dream House Project Presentation
Dream House Project PresentationDream House Project Presentation
Dream House Project Presentation
 

Semelhante a Practical MongoDB

Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of usOSCON Byrum
 
Evolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchEvolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchMongoDB
 
Tools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 EditionTools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 EditionJesus Manuel Olivas
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6Maxime Beugnet
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"South Tyrol Free Software Conference
 
MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...
MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...
MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...MongoDB
 
Scott Guthrie at Dot Net Startup meetup
Scott Guthrie at Dot Net Startup meetupScott Guthrie at Dot Net Startup meetup
Scott Guthrie at Dot Net Startup meetupMarcelo Calbucci
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDBNate Abele
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4DEVCON
 
Mocks, Proxies, and Transpilation as Development Strategies for Web Development
Mocks, Proxies, and Transpilation as Development Strategies for Web DevelopmentMocks, Proxies, and Transpilation as Development Strategies for Web Development
Mocks, Proxies, and Transpilation as Development Strategies for Web DevelopmentESUG
 
Analytics with MongoDB Aggregation Framework and Hadoop Connector
Analytics with MongoDB Aggregation Framework and Hadoop ConnectorAnalytics with MongoDB Aggregation Framework and Hadoop Connector
Analytics with MongoDB Aggregation Framework and Hadoop ConnectorHenrik Ingo
 
Powering Systems of Engagement
Powering Systems of EngagementPowering Systems of Engagement
Powering Systems of EngagementMongoDB
 
MongoDB Evenings Dallas: What's the Scoop on MongoDB & Hadoop
MongoDB Evenings Dallas: What's the Scoop on MongoDB & HadoopMongoDB Evenings Dallas: What's the Scoop on MongoDB & Hadoop
MongoDB Evenings Dallas: What's the Scoop on MongoDB & HadoopMongoDB
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMichael Dawson
 

Semelhante a Practical MongoDB (20)

Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
Evolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchEvolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB Stitch
 
Tools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 EditionTools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 Edition
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
 
MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...
MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...
MongoDB Evenings Houston: What's the Scoop on MongoDB and Hadoop? by Jake Ang...
 
API Design - 3rd Edition
API Design - 3rd EditionAPI Design - 3rd Edition
API Design - 3rd Edition
 
Scott Guthrie at Dot Net Startup meetup
Scott Guthrie at Dot Net Startup meetupScott Guthrie at Dot Net Startup meetup
Scott Guthrie at Dot Net Startup meetup
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Talk MongoDB - Amil
Talk MongoDB - AmilTalk MongoDB - Amil
Talk MongoDB - Amil
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4
 
Mocks, Proxies, and Transpilation as Development Strategies for Web Development
Mocks, Proxies, and Transpilation as Development Strategies for Web DevelopmentMocks, Proxies, and Transpilation as Development Strategies for Web Development
Mocks, Proxies, and Transpilation as Development Strategies for Web Development
 
Analytics with MongoDB Aggregation Framework and Hadoop Connector
Analytics with MongoDB Aggregation Framework and Hadoop ConnectorAnalytics with MongoDB Aggregation Framework and Hadoop Connector
Analytics with MongoDB Aggregation Framework and Hadoop Connector
 
Powering Systems of Engagement
Powering Systems of EngagementPowering Systems of Engagement
Powering Systems of Engagement
 
MongoDB Evenings Dallas: What's the Scoop on MongoDB & Hadoop
MongoDB Evenings Dallas: What's the Scoop on MongoDB & HadoopMongoDB Evenings Dallas: What's the Scoop on MongoDB & Hadoop
MongoDB Evenings Dallas: What's the Scoop on MongoDB & Hadoop
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive Boston
 
Micro app-framework
Micro app-frameworkMicro app-framework
Micro app-framework
 

Mais de Will Button

Build an Infra Product with AWS Fargate
Build an Infra Product with AWS FargateBuild an Infra Product with AWS Fargate
Build an Infra Product with AWS FargateWill Button
 
DevOps for Developers
DevOps for DevelopersDevOps for Developers
DevOps for DevelopersWill Button
 
Deploy Nodejs on Docker
Deploy Nodejs on DockerDeploy Nodejs on Docker
Deploy Nodejs on DockerWill Button
 
Effective Telepresence and Remote Collaboration
Effective Telepresence and Remote CollaborationEffective Telepresence and Remote Collaboration
Effective Telepresence and Remote CollaborationWill Button
 
No More Mr. Nice Guy The MEAN Stack
No More Mr. Nice Guy   The MEAN StackNo More Mr. Nice Guy   The MEAN Stack
No More Mr. Nice Guy The MEAN StackWill Button
 
Mongo Sharding: Case Study
Mongo Sharding: Case StudyMongo Sharding: Case Study
Mongo Sharding: Case StudyWill Button
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101Will Button
 
Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Will Button
 

Mais de Will Button (9)

Build an Infra Product with AWS Fargate
Build an Infra Product with AWS FargateBuild an Infra Product with AWS Fargate
Build an Infra Product with AWS Fargate
 
DevOps for Developers
DevOps for DevelopersDevOps for Developers
DevOps for Developers
 
Deploy Nodejs on Docker
Deploy Nodejs on DockerDeploy Nodejs on Docker
Deploy Nodejs on Docker
 
Effective Telepresence and Remote Collaboration
Effective Telepresence and Remote CollaborationEffective Telepresence and Remote Collaboration
Effective Telepresence and Remote Collaboration
 
Traxticsearch
TraxticsearchTraxticsearch
Traxticsearch
 
No More Mr. Nice Guy The MEAN Stack
No More Mr. Nice Guy   The MEAN StackNo More Mr. Nice Guy   The MEAN Stack
No More Mr. Nice Guy The MEAN Stack
 
Mongo Sharding: Case Study
Mongo Sharding: Case StudyMongo Sharding: Case Study
Mongo Sharding: Case Study
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101
 
Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Mongo db mug_2012-02-07
Mongo db mug_2012-02-07
 

Último

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Último (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

Practical MongoDB

  • 1. Will Button - @wfbutton Practical MongoDB
  • 2. From template to production Many resources exist for individual components. Getting them to work together is a different story.
  • 3. { name: ‘Will Button’, contact: [twitter: ‘@wfbutton’, email: ‘willb@mylist.com’, web: ‘www.two4seven.me’], role: [‘dev’, ‘ops’, ‘it’], company: ‘myList.com’ }
  • 5. The problem. Participants competing in a challenge log meals, workouts and health data into a private Facebook group Facebook newsfeed algorithm No reporting Don’t want to lose demographics Can we use existing frameworks to make it better without losing the parts that work well?
  • 7.
  • 8. Step 1: MEAN Stack Template git clone http://github.com/linnovate/mean.git
  • 11. Facebook Permissions Default: profile, friends list, email Can’t read newsfeed by default Reading newsfeed requires valid accessToken
  • 13. What about this accessToken thing? > db.users.findOne({ provider: "facebook" }) { "__v" : 0, "_id" : ObjectId("52f6fc252ae38687577cc688"), "currentchallenge" : ObjectId("5308d9756d7d30a94b681b2d"), "email" : "will@paleotracking.com", "facebook" : { "username" : "will.button.56", "updated_time" : "2014-01-06T22:33:03+0000", "verified" : true, "locale" : "en_US", "timezone" : -7, "email" : "wfbutton@gmail.com", "gender" : "male", "education" : [ { "type" : "High School", "school" : { "name" : "Sidney High School", "id" : "110094965686846" } } ], "favorite_athletes" : [ { "name" : "CrossFit Endurance", "id" : "182015510972" }, { "name" : "Lucas Parker", "id" : "346667935460586" } ], "favorite_teams" : [ { "name" : "Dallas Cowboys", "id" : "99559607813" } ], "work" : [ { "start_date" : "0000-00", "employer" : { "name" : "myList", "id" : "105017792957809" } }, { "end_date" : "0000-00", "start_date" : "2004-07-01", "employer" : { "name" : "NightHawk Radiology Services", "id" : "115173631830635" } } ], "bio" : "CrossFit Level 1 (CF-L1) Trainer", "location" : { "name" : "Jost Van Dyke, British Virgin Islands", "id" : "327610993996350" }, "hometown" : { "name" : "Sidney, Texas", "id" : "108011082555210" }, "link" : "https://www.facebook.com/will.button.56", "last_name" : "Button", "first_name" : "Will", "name" : "Will Button", "id" : "100001902024344" }, "name" : "Will Button", "provider" : "facebook", "username" : "will.button.56" All of this for FREE $$$$ But no accessToken 
  • 15. User.js Model Updated user.js model to store accessToken
  • 18.
  • 19.
  • 20. Stored Documents { "user" : ObjectId("52f6fc252ae38687577cc688"), "message" : "I ate my stuff", "challenge" : ObjectId("5302e4e445bae1611e2e60d9"), "_id" : ObjectId("53125a106184fe00006e46d6"), "likes" : { "data" : [ ] }, "comments" : { "data" : [ ] }, "updated_time" : ISODate("2014-03- 01T22:07:12.442Z"), "created_time" : ISODate("2014-03- 01T22:07:12.442Z"), "__v" : 0
  • 21. Journal Data Model var JournalSchema = new Schema({ created_time: { type: Date, default: Date.now }, updated_time: { type: Date, default: Date.now }, message: { type: String }, comments: { data: [CommentSchema] }, likes: { data: [LikesSchema] }, user: { type: Schema.ObjectId, ref: 'User' }, challenge: { type: Schema.ObjectId, ref: 'Challenge' } }); var LikesSchema = new Schema({ id: { type: String }, name: { type: String } });
  • 22. Controller (part of it anyway)
  • 24. Recap: Where are we now?
  • 27. Aggregation : Quick Review Pipeline for multiple stages of document transformations for producing aggregated results Name Description $project Reshapes a document stream. $project can rename, add, or remove fields as well as create computed values and sub-documents. $match Filters the document stream, and only allows matching documents to pass into the next pipeline stage. $match uses standard MongoDB queries. $limit Restricts the number of documents in an aggregation pipeline. $skip Skips over a specified number of documents from the pipeline and returns the rest. $unwind Takes an array of documents and returns them as a stream of documents. $group Groups documents together for the purpose of calculating aggregate values based on a collection of documents. $sort Takes all input documents and returns them in a stream of sorted documents. $geoNear Returns an ordered stream of documents based on proximity to a geospatial point.
  • 28. db.journals.aggregate( { $group: { _id: "$from.name", numposts: { $sum: 1 } } }, { $project: { who: "$from.name", numposts: 1 } }, { $sort: {_id: 1 } } ) { "result" : [ { "_id" : "Andrew", "numposts" : 83 }, { "_id" : "Ben", "numposts" : 108 }, ########### results truncated for brevity ########## { "_id" : "Tara", "numposts" : 20 }, { "_id" : "Will", "numposts" : 26 } ], "ok" : 1 }
  • 30. Page is rendered By a controller With a directive Using D3 injected as a service
  • 31. The Controller angular.module('mean.reports').controller('ReportsController', ['$scope', '$http', function($scope, $http){ $http({ method: 'GET', url: '/journals/ppu' }).then(function(data, status) { $scope.d3Data = data.data; }); }]);
  • 33. d3Bars Directive D3 library injected as a service
  • 34. The d3 service is accessible because we add the service to our footer And inject it as a dependency
  • 35. The service itself simply downloads d3.js
  • 36. Directives are just reusable pieces of code Restrict where the directive can be used A/E/C Scope refers to the type of isolated scope: =  two way data binding with the parent DOM object @  one way data binding with the parent DOM object &  expression binding with the parent DOM object
  • 37. link is basically a controller variables either specified on declaration or use defaults
  • 38.
  • 39. Where do we go from here?
  • 40. Where do we go from here? Add new aggregation queries to journals controller Build new reports/d3 visualizations in directives.js Add directives to any page: <d3-bars data="d3Data”></d3-bars>
  • 41. The mistakes people I make. Request the right Facebook permissions Setup your Facebook Developers Account Make your Facebook app public (at least for a few minutes) Facebook Graph Explorer Hardcode dummy data first. Don’t assume .success(), wait for it .then()
  • 42. Do this now: • Clone the MEAN stack • Stub out dummy data • Build a d3 graph • Stick around