SlideShare a Scribd company logo

Mongo db ecommerce

C
christkv

A simple schema design set for modeling a product, category and cart for an eCommerce system using mongodb

1 of 21
Download to read offline
Simple e-commerce schema
Christian Kvalheim @christkv
Agenda
• The product
• The categories
• Product by categories
• Category navigation
• The cart
• Add product to cart
• Remove product from cart
• Expire cart
• The checkout
The product
 {
     sku: "111445GB3",
     title: "Simsong One mobile phone",
     description: "The greatest Onedroid phone on the market .....",

     manufacture_details: {
        model_number: "A123X",
        release_date: new ISODate("2012-05-17T08:14:15.656Z")
     },
     shipping_details: {
        weight: 350,
        width: 10,
        height: 10,
        depth: 1
     },
     quantity: 99,
     pricing: {
        price: 1000
     }
 }
The product, add categories
db.products.update(
  {sku: "111445GB3"},
  {$set: { categories: ['mobile/15G', 'mobile/fm'] }});


  {
    sku: "111445GB3",
    title: "Simsong One mobile phone",
    description: "The greatest Onedroid phone on the market .....",
    manufacture_details: {
       model_number: "A123X", release_date: new
  ISODate("2012-05-17T08:14:15.656Z")
    },
    shipping_details: {
       weight: 350, width: 10, height: 10, depth: 1
    },
    quantity: 99,

   categories: ['mobile/15G', 'mobile/
  fm'],
The product, add categories
• Add an index on the categories
db.products.ensureIndex({categories:1 })



• Locate all the products in a category
db.products.find({categories: /^mobile/fm/})



• If we use case sensitive pre-fix regular expressions
  we use the btree index and have very fast lookups
Categories
  {
      title: "Mobiles containing a FM radio",
      parent: "mobile",
      path: "mobile/fm"
  }


db.categories.insert({title: "Mobiles containing a FM radio", parent:
"mobile", path: "mobile/fm"})

db.categories.insert({title: "Mobiles with 15G support", parent:
"mobile", path: "mobile/15G"})

db.categories.ensureIndex({parent: 1, path: 1})

db.categories.ensureIndex({path: 1})

Recommended

Projeto: Identidade e Valores através dos Contos Infantis
Projeto: Identidade e Valores através dos Contos InfantisProjeto: Identidade e Valores através dos Contos Infantis
Projeto: Identidade e Valores através dos Contos InfantisRoberta Silva
 
Leitura na educação infantil slide 2014
Leitura na educação infantil slide 2014Leitura na educação infantil slide 2014
Leitura na educação infantil slide 2014MariaScalet
 
Projeto os três porquinhos
Projeto os três porquinhosProjeto os três porquinhos
Projeto os três porquinhossandramirandan
 
Dia Das CriançAs
Dia Das CriançAsDia Das CriançAs
Dia Das CriançAsveroleal
 

More Related Content

What's hot

Portfólio de atividades da Helena - 1º semestre de 2013
Portfólio de atividades da Helena - 1º semestre de 2013Portfólio de atividades da Helena - 1º semestre de 2013
Portfólio de atividades da Helena - 1º semestre de 2013Helena de Brum
 
Projeto era uma vez as letras do meu nome por todos os lugares do CMEI!
Projeto era uma vez  as letras do meu nome por todos os lugares do CMEI!Projeto era uma vez  as letras do meu nome por todos os lugares do CMEI!
Projeto era uma vez as letras do meu nome por todos os lugares do CMEI!Renata Damasceno
 
Aula 3 biblioteca publica
Aula 3 biblioteca publicaAula 3 biblioteca publica
Aula 3 biblioteca publicaBiblio 2010
 
PROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITA
PROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITAPROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITA
PROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITAJane Santos
 
Histórias contadas e cantadas
Histórias contadas e cantadasHistórias contadas e cantadas
Histórias contadas e cantadasdafiny9999
 
CALENDÁRIO ESCOLAR SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...
CALENDÁRIO ESCOLAR  SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...CALENDÁRIO ESCOLAR  SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...
CALENDÁRIO ESCOLAR SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...Antônio Fernandes
 
Há cor na educação ( projeto elaborado para o pacto 2013)
Há cor na educação ( projeto elaborado para o pacto 2013)Há cor na educação ( projeto elaborado para o pacto 2013)
Há cor na educação ( projeto elaborado para o pacto 2013)Juciara Brito
 
Conto torrado nuvem.caracol_Clara
Conto torrado nuvem.caracol_ClaraConto torrado nuvem.caracol_Clara
Conto torrado nuvem.caracol_ClaraClara Sousa
 
Animais na Educação Infantil
Animais na Educação InfantilAnimais na Educação Infantil
Animais na Educação InfantilAraujo Adeilza
 
Livro infantil charalina livro infantil charalina imprimir
Livro infantil charalina   livro infantil charalina imprimirLivro infantil charalina   livro infantil charalina imprimir
Livro infantil charalina livro infantil charalina imprimirAugusto Bertotto
 
Sequencia didatica 10 de fevereriro a 28 de março amada n
Sequencia didatica  10  de fevereriro a 28 de março  amada nSequencia didatica  10  de fevereriro a 28 de março  amada n
Sequencia didatica 10 de fevereriro a 28 de março amada njulliana brito
 
Projeto brincadeira de criança
Projeto brincadeira de criançaProjeto brincadeira de criança
Projeto brincadeira de criançadanizinha_blog
 
PROJETO:FIGURAS, CORES E FORMAS
PROJETO:FIGURAS, CORES E FORMASPROJETO:FIGURAS, CORES E FORMAS
PROJETO:FIGURAS, CORES E FORMASguest3a9cb
 
21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar
21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar
21655835 a-indissociabilidade-entre-educar-cuidar-e-brincarEduardo Lopes
 

What's hot (20)

NATAL - LIVRO INFANTIL.pdf
NATAL - LIVRO INFANTIL.pdfNATAL - LIVRO INFANTIL.pdf
NATAL - LIVRO INFANTIL.pdf
 
Portfólio de atividades da Helena - 1º semestre de 2013
Portfólio de atividades da Helena - 1º semestre de 2013Portfólio de atividades da Helena - 1º semestre de 2013
Portfólio de atividades da Helena - 1º semestre de 2013
 
Projeto era uma vez as letras do meu nome por todos os lugares do CMEI!
Projeto era uma vez  as letras do meu nome por todos os lugares do CMEI!Projeto era uma vez  as letras do meu nome por todos os lugares do CMEI!
Projeto era uma vez as letras do meu nome por todos os lugares do CMEI!
 
2ºencontro coordenadores (1)
2ºencontro coordenadores (1)2ºencontro coordenadores (1)
2ºencontro coordenadores (1)
 
Aula 3 biblioteca publica
Aula 3 biblioteca publicaAula 3 biblioteca publica
Aula 3 biblioteca publica
 
PROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITA
PROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITAPROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITA
PROJETO DE LEITURA: UM PALCO PARA A LINGUAGEM ORAL E ESCRITA
 
Histórias contadas e cantadas
Histórias contadas e cantadasHistórias contadas e cantadas
Histórias contadas e cantadas
 
CALENDÁRIO ESCOLAR SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...
CALENDÁRIO ESCOLAR  SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...CALENDÁRIO ESCOLAR  SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...
CALENDÁRIO ESCOLAR SEE-MG PARA 2014. ANO DA COPA DO MUNDO.Resolução see nº 2...
 
Há cor na educação ( projeto elaborado para o pacto 2013)
Há cor na educação ( projeto elaborado para o pacto 2013)Há cor na educação ( projeto elaborado para o pacto 2013)
Há cor na educação ( projeto elaborado para o pacto 2013)
 
Conto torrado nuvem.caracol_Clara
Conto torrado nuvem.caracol_ClaraConto torrado nuvem.caracol_Clara
Conto torrado nuvem.caracol_Clara
 
Projeto educação infantil etnico racial
Projeto educação infantil etnico racialProjeto educação infantil etnico racial
Projeto educação infantil etnico racial
 
Animais na Educação Infantil
Animais na Educação InfantilAnimais na Educação Infantil
Animais na Educação Infantil
 
Pinóquio
PinóquioPinóquio
Pinóquio
 
Projeto animais da fazenda 2 anos 2014
Projeto animais da fazenda 2 anos 2014Projeto animais da fazenda 2 anos 2014
Projeto animais da fazenda 2 anos 2014
 
Livro infantil charalina livro infantil charalina imprimir
Livro infantil charalina   livro infantil charalina imprimirLivro infantil charalina   livro infantil charalina imprimir
Livro infantil charalina livro infantil charalina imprimir
 
Sequencia didatica 10 de fevereriro a 28 de março amada n
Sequencia didatica  10  de fevereriro a 28 de março  amada nSequencia didatica  10  de fevereriro a 28 de março  amada n
Sequencia didatica 10 de fevereriro a 28 de março amada n
 
Projeto brincadeira de criança
Projeto brincadeira de criançaProjeto brincadeira de criança
Projeto brincadeira de criança
 
Projeto Mala Viajante
Projeto Mala ViajanteProjeto Mala Viajante
Projeto Mala Viajante
 
PROJETO:FIGURAS, CORES E FORMAS
PROJETO:FIGURAS, CORES E FORMASPROJETO:FIGURAS, CORES E FORMAS
PROJETO:FIGURAS, CORES E FORMAS
 
21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar
21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar
21655835 a-indissociabilidade-entre-educar-cuidar-e-brincar
 

Similar to Mongo db ecommerce

MongoDB World 2018: Keynote
MongoDB World 2018: KeynoteMongoDB World 2018: Keynote
MongoDB World 2018: KeynoteMongoDB
 
Retail Reference Architecture Part 2: Real-Time, Geo Distributed Inventory
Retail Reference Architecture Part 2: Real-Time, Geo Distributed InventoryRetail Reference Architecture Part 2: Real-Time, Geo Distributed Inventory
Retail Reference Architecture Part 2: Real-Time, Geo Distributed InventoryMongoDB
 
Query for json databases
Query for json databasesQuery for json databases
Query for json databasesBinh Le
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSONChris Saxon
 
GraphQL: APIs the New Way.
GraphQL: APIs the New Way.GraphQL: APIs the New Way.
GraphQL: APIs the New Way.EatDog
 
- Prewritten codes main-cpp- #include -iostream- #include-Shoppi.pdf
- Prewritten codes    main-cpp-    #include -iostream- #include-Shoppi.pdf- Prewritten codes    main-cpp-    #include -iostream- #include-Shoppi.pdf
- Prewritten codes main-cpp- #include -iostream- #include-Shoppi.pdfsyedazmath9
 
GraphQL - APIs The New Way
GraphQL - APIs The New WayGraphQL - APIs The New Way
GraphQL - APIs The New WayVladimir Tsukur
 
Introduction to type classes in 30 min
Introduction to type classes in 30 minIntroduction to type classes in 30 min
Introduction to type classes in 30 minPawel Szulc
 
MongoDB World 2019: Just-in-time Validation with JSON Schema
MongoDB World 2019: Just-in-time Validation with JSON SchemaMongoDB World 2019: Just-in-time Validation with JSON Schema
MongoDB World 2019: Just-in-time Validation with JSON SchemaMongoDB
 
Introduction to type classes
Introduction to type classesIntroduction to type classes
Introduction to type classesPawel Szulc
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBMongoDB
 
CodingSerbia2014-JavaVSPig
CodingSerbia2014-JavaVSPigCodingSerbia2014-JavaVSPig
CodingSerbia2014-JavaVSPigDusan Zamurovic
 
Webinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBWebinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBMongoDB
 
Migrating one of the most popular e commerce platforms to mongodb
Migrating one of the most popular e commerce platforms to mongodbMigrating one of the most popular e commerce platforms to mongodb
Migrating one of the most popular e commerce platforms to mongodbMongoDB
 
Migrating One of the Most Popular eCommerce Platforms to MongoDB
Migrating One of the Most Popular eCommerce Platforms to MongoDBMigrating One of the Most Popular eCommerce Platforms to MongoDB
Migrating One of the Most Popular eCommerce Platforms to MongoDBMongoDB
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichNorberto Leite
 
GraphQL APIs in Scala with Sangria
GraphQL APIs in Scala with SangriaGraphQL APIs in Scala with Sangria
GraphQL APIs in Scala with SangriaVladimir Tsukur
 

Similar to Mongo db ecommerce (20)

MongoDB World 2018: Keynote
MongoDB World 2018: KeynoteMongoDB World 2018: Keynote
MongoDB World 2018: Keynote
 
Retail Reference Architecture Part 2: Real-Time, Geo Distributed Inventory
Retail Reference Architecture Part 2: Real-Time, Geo Distributed InventoryRetail Reference Architecture Part 2: Real-Time, Geo Distributed Inventory
Retail Reference Architecture Part 2: Real-Time, Geo Distributed Inventory
 
Query for json databases
Query for json databasesQuery for json databases
Query for json databases
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSON
 
RESTful services Design Lab
RESTful services Design LabRESTful services Design Lab
RESTful services Design Lab
 
GraphQL: APIs the New Way.
GraphQL: APIs the New Way.GraphQL: APIs the New Way.
GraphQL: APIs the New Way.
 
- Prewritten codes main-cpp- #include -iostream- #include-Shoppi.pdf
- Prewritten codes    main-cpp-    #include -iostream- #include-Shoppi.pdf- Prewritten codes    main-cpp-    #include -iostream- #include-Shoppi.pdf
- Prewritten codes main-cpp- #include -iostream- #include-Shoppi.pdf
 
GraphQL - APIs The New Way
GraphQL - APIs The New WayGraphQL - APIs The New Way
GraphQL - APIs The New Way
 
Introduction to type classes in 30 min
Introduction to type classes in 30 minIntroduction to type classes in 30 min
Introduction to type classes in 30 min
 
MongoDB World 2019: Just-in-time Validation with JSON Schema
MongoDB World 2019: Just-in-time Validation with JSON SchemaMongoDB World 2019: Just-in-time Validation with JSON Schema
MongoDB World 2019: Just-in-time Validation with JSON Schema
 
MongoDB With Style
MongoDB With StyleMongoDB With Style
MongoDB With Style
 
Introduction to type classes
Introduction to type classesIntroduction to type classes
Introduction to type classes
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDB
 
CodingSerbia2014-JavaVSPig
CodingSerbia2014-JavaVSPigCodingSerbia2014-JavaVSPig
CodingSerbia2014-JavaVSPig
 
Webinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBWebinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDB
 
Migrating one of the most popular e commerce platforms to mongodb
Migrating one of the most popular e commerce platforms to mongodbMigrating one of the most popular e commerce platforms to mongodb
Migrating one of the most popular e commerce platforms to mongodb
 
Migrating One of the Most Popular eCommerce Platforms to MongoDB
Migrating One of the Most Popular eCommerce Platforms to MongoDBMigrating One of the Most Popular eCommerce Platforms to MongoDB
Migrating One of the Most Popular eCommerce Platforms to MongoDB
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
GraphQL APIs in Scala with Sangria
GraphQL APIs in Scala with SangriaGraphQL APIs in Scala with Sangria
GraphQL APIs in Scala with Sangria
 

More from christkv

From SQL to MongoDB
From SQL to MongoDBFrom SQL to MongoDB
From SQL to MongoDBchristkv
 
New in MongoDB 2.6
New in MongoDB 2.6New in MongoDB 2.6
New in MongoDB 2.6christkv
 
Lessons from 4 years of driver develoment
Lessons from 4 years of driver develomentLessons from 4 years of driver develoment
Lessons from 4 years of driver develomentchristkv
 
Storage talk
Storage talkStorage talk
Storage talkchristkv
 
Cdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupCdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupchristkv
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
Schema design
Schema designSchema design
Schema designchristkv
 
Node js mongodriver
Node js mongodriverNode js mongodriver
Node js mongodriverchristkv
 
Node.js and ruby
Node.js and rubyNode.js and ruby
Node.js and rubychristkv
 

More from christkv (9)

From SQL to MongoDB
From SQL to MongoDBFrom SQL to MongoDB
From SQL to MongoDB
 
New in MongoDB 2.6
New in MongoDB 2.6New in MongoDB 2.6
New in MongoDB 2.6
 
Lessons from 4 years of driver develoment
Lessons from 4 years of driver develomentLessons from 4 years of driver develoment
Lessons from 4 years of driver develoment
 
Storage talk
Storage talkStorage talk
Storage talk
 
Cdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupCdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetup
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
Schema design
Schema designSchema design
Schema design
 
Node js mongodriver
Node js mongodriverNode js mongodriver
Node js mongodriver
 
Node.js and ruby
Node.js and rubyNode.js and ruby
Node.js and ruby
 

Recently uploaded

Enterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book ReviewEnterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book ReviewAshraf Fouad
 
Dynamical systems simulation in Python for science and engineering
Dynamical systems simulation in Python for science and engineeringDynamical systems simulation in Python for science and engineering
Dynamical systems simulation in Python for science and engineeringMassimo Talia
 
Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...
Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...
Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...Product School
 
"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor Fesenko"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor FesenkoFwdays
 
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes", Volodymyr TsapFwdays
 
10 things that helped me advance my career - PHP UK Conference 2024
10 things that helped me advance my career - PHP UK Conference 202410 things that helped me advance my career - PHP UK Conference 2024
10 things that helped me advance my career - PHP UK Conference 2024Thijs Feryn
 
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24Umar Saif
 
Leveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docx
Leveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docxLeveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docx
Leveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docxVotarikari Shravan
 
AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...
AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...
AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...ISPMAIndia
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsEvangelia Mitsopoulou
 
LF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIELF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIEDanBrown980551
 
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERNRonnelBaroc
 
Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?MENGSAYLOEM1
 
From Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+PluginsFrom Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+PluginsInflectra
 
How to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response PlanHow to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response PlanDatabarracks
 
How we think about an advisor tech stack
How we think about an advisor tech stackHow we think about an advisor tech stack
How we think about an advisor tech stackSummit
 
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...Adrian Sanabria
 
HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...
HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...
HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...htrindia
 
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, GoogleISPMAIndia
 
Power of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdfPower of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdfkatalinjordans1
 

Recently uploaded (20)

Enterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book ReviewEnterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book Review
 
Dynamical systems simulation in Python for science and engineering
Dynamical systems simulation in Python for science and engineeringDynamical systems simulation in Python for science and engineering
Dynamical systems simulation in Python for science and engineering
 
Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...
Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...
Cultivating Entrepreneurial Mindset in Product Management: Strategies for Suc...
 
"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor Fesenko"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor Fesenko
 
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
 
10 things that helped me advance my career - PHP UK Conference 2024
10 things that helped me advance my career - PHP UK Conference 202410 things that helped me advance my career - PHP UK Conference 2024
10 things that helped me advance my career - PHP UK Conference 2024
 
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
 
Leveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docx
Leveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docxLeveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docx
Leveraging SLF4j for Effective Logging in IBM App Connect Enterprise.docx
 
AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...
AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...
AI MODELS USAGE IN FINTECH PRODUCTS: PM APPROACH & BEST PRACTICES by Kasthuri...
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applications
 
LF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIELF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIE
 
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
 
Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?
 
From Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+PluginsFrom Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
 
How to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response PlanHow to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response Plan
 
How we think about an advisor tech stack
How we think about an advisor tech stackHow we think about an advisor tech stack
How we think about an advisor tech stack
 
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
 
HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...
HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...
HBR SERIES METAL HOUSED RESISTORS POWER ELECTRICAL ABSORBS HIGH CURRENT DURIN...
 
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
 
Power of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdfPower of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdf
 

Mongo db ecommerce

  • 2. Agenda • The product • The categories • Product by categories • Category navigation • The cart • Add product to cart • Remove product from cart • Expire cart • The checkout
  • 3. The product { sku: "111445GB3", title: "Simsong One mobile phone", description: "The greatest Onedroid phone on the market .....", manufacture_details: { model_number: "A123X", release_date: new ISODate("2012-05-17T08:14:15.656Z") }, shipping_details: { weight: 350, width: 10, height: 10, depth: 1 }, quantity: 99, pricing: { price: 1000 } }
  • 4. The product, add categories db.products.update( {sku: "111445GB3"}, {$set: { categories: ['mobile/15G', 'mobile/fm'] }}); { sku: "111445GB3", title: "Simsong One mobile phone", description: "The greatest Onedroid phone on the market .....", manufacture_details: { model_number: "A123X", release_date: new ISODate("2012-05-17T08:14:15.656Z") }, shipping_details: { weight: 350, width: 10, height: 10, depth: 1 }, quantity: 99, categories: ['mobile/15G', 'mobile/ fm'],
  • 5. The product, add categories • Add an index on the categories db.products.ensureIndex({categories:1 }) • Locate all the products in a category db.products.find({categories: /^mobile/fm/}) • If we use case sensitive pre-fix regular expressions we use the btree index and have very fast lookups
  • 6. Categories { title: "Mobiles containing a FM radio", parent: "mobile", path: "mobile/fm" } db.categories.insert({title: "Mobiles containing a FM radio", parent: "mobile", path: "mobile/fm"}) db.categories.insert({title: "Mobiles with 15G support", parent: "mobile", path: "mobile/15G"}) db.categories.ensureIndex({parent: 1, path: 1}) db.categories.ensureIndex({path: 1})
  • 7. Categories, queries • Locate all categories directly under /mobile db.categories.find({parent: /^mobile/}, {_id: 0, path: 1}) • Locate all the categories under /mobile db.categories.find({path: /^mobile/}, {_id: 0, path: 1})
  • 9. Cart, example schema { _id: "the_users_session_id", status:'active' quantity: 2, total: 2000, products: [] } • Add item to cart • Update inventory only if we have enough quantity • Rollback if inventory update fails
  • 10. Cart, add item to cart db.carts.update({ _id: "the_users_session_id", status:'active' }, { $set: { modified_on: ISODate() }, $push: { products: { sku: "111445GB3", quantity: 1, title: "Simsong One mobile phone", price:1000 } } }); { _id: "the_users_session_id", status:'active' quantity: 2, total: 2000, products: [{sku: "111445GB3", quantity: 1, title: "Simsong One mobile phone", price:1000}] }
  • 11. Cart, add to cart, inventory cover db.products.update({ sku: "111445GB3", quantity: {$gte: 1} }, { $inc: {quantity: -1}, $push: { in_carts: { quantity:1, id: "the_users_session_id", timestamp: new ISODate() } } • If we did not update the stock, roll back cart add if(!db.runCommand({getLastError:1}).updatedExisting) { db.carts.update({ _id: "the_users_session_id" }, { $pull: {products: {sku:"111445GB3"}} }) }
  • 13. Cart, update quantity db.carts.update({ _id: "the_users_session_id", "products.sku": "111445GB3", status: "active" }, { $set: { modified_on: new ISODate(), "products.$.qty": new_quantity } }) • Update the quantity in the cart • new_quantity = 2 • old_quantity = 1 • delta_quantity = new_quantity - old_quantity
  • 14. Cart, update inventory db.products.update({ sku: "111445GB3", "in_carts.id": "the_users_session_id", quantity: { $gte: 1 } }, { $inc: { quantity: (-1)*delta_quantity }, $set: { "in_carts.$.quantity": new_quantity, timestamp: new ISODate() } }) • Attempt to update the inventory • new_quantity = 2 • old_quantity = 1 • delta_quantity = new_quantity - old_quantity
  • 15. Cart, on failure rollback if(!db.runCommand({getLastError:1}).updatedExisting) { db.carts.update({ _id: "the_users_session_id", "products.sku": "111445GB3" }, { $set : { "in_carts.$.quantity": old_quantity} }) } • If the update fails roll back the cart to the previous quantity • new_quantity = 2 • old_quantity = 1 • delta_quantity = new_quantity - old_quantity
  • 17. Cart, expire all the carts var carts = db.carts.find({status:"expiring"}) for(var i = 0; i < carts.length; i++) { var cart = carts[i] for(var j = 0; j < cart.products.length; j++) { var product = cart.products[i] db.products.update({ sku: product.sku, "in_carts.id": cart._id, "in_carts.quantity": product.quantity }, { $inc: {quantity: item.quantity}, $pull: {in_carts: {id: cart._id}} }) } db.carts.update({ _id: cart._id, $set: {status: 'expired'} }) }
  • 19. Insert an Order db.orders.insert({ created_on: new ISODate("2012-05-17T08:14:15.656Z"), shipping: { customer: "Peter P Peterson", address: "Longroad 1343", city: "Peterburg", region: "", state: "PE", country: "Peteonia", delivery_notes: "Leave at the gate", tracking: { company: "ups", tracking_number: "22122X211SD", status: "ontruck", estimated_delivery: new ISODate("2012-05-17T08:14:15.656Z") }, }, payment: { method: "visa", transaction_id: "2312213312XXXTD" } products: { {quantity: 2, sku:"111445GB3", title: "Simsong mobile phone", unit_cost:1000, currency:"USD"} } })
  • 20. Cart, finish up and clean up db.carts.update({ _id: "the_users_session_id" }, { $set: {status:"complete"} }); • Set the cart status as completed db.products.update({ "in_carts.id": "the_users_session_id" }, { $pull: {in_carts: {id: "the_users_session_id"}} }, false, true); • Remove all carts from products
  • 21. Thank you and happy schemaing twitter: @christkv

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n