mongodb 101

20
MONGODB 101 Introduction to document database PHPers.02 15 lipca 2013 Leszek Krupiński @leafnode

Upload: leafnode

Post on 08-Apr-2017

180 views

Category:

Software


0 download

TRANSCRIPT

Page 1: MongoDB 101

MONGODB 101Introduction to document database

PHPers.0215 lipca 2013

Leszek Krupiński@leafnode

Page 2: MongoDB 101

BASICSNoSQL and document databases

Page 3: MongoDB 101

MONGODBDocument database, object store

Page 4: MongoDB 101

REPLICATION AND SHARDING

OOTB

Page 5: MongoDB 101

GEOSPATIAL INDEX

Page 6: MongoDB 101

JSON BSON

{ _id : ObjectId("51d66af57d3afb7a973b00ab"), username : 'foo', firstName : 'John', lastName : 'Smith', address : { street : ‘5th N', city : ‘New York', zip : '00001' } friends : [ 'bill', 'frank', 'mike' ] }

Page 7: MongoDB 101

QUERIESCRUD

Page 8: MongoDB 101

FIND

Page 9: MongoDB 101

INSERT

Page 10: MongoDB 101

UPDATE3 ways

Page 11: MongoDB 101

REMOVE

Page 12: MongoDB 101

PROJEKTOWANIE SCHEMATUSchemaless != Don’t plan

Page 13: MongoDB 101

RELATIONAL MODEL

Page 14: MongoDB 101

DOCUMENT MODEL{ _id : ObjectId("51d66af57d3afb7a973b00ab"), author : 'john', title : 'Interesting post', body : 'Lorem Ipsum', date : ISODate("2012-12-19T20:10:56.920Z"), tags : [ 'lorem', 'lifestyle', 'eating' ], comments : [ { author : 'Anonymous', date : ISODate("2012-12-19T20:10:56.920Z"), body : 'Boooring!' }, { author : 'Frankie', date : ISODate("2012-12-19T20:10:56.920Z"), body : ‘Not boring at all.' } ] }

Page 15: MongoDB 101

GEOSPATIAL INDEXdb.places.ensureIndex( { location: ‘2d’ } )

Page 16: MongoDB 101

db.places.find( { location: { $near : [ 52, 21 ] } } )

Page 17: MongoDB 101

MONGODB AND PHPpecl install mongo

Page 18: MongoDB 101

DEMO

Page 19: MongoDB 101

DOCTRINEDEMO

Page 20: MongoDB 101

SIDENOTE$qb = $dm->createQueryBuilder('Application_Model_Entry')

->field('club.$id')->equals(new MongoId($club->getId()));