MONGODB 101
Introduction to document database
PHPers.02
15 lipca 2013
Leszek Krupiński
@leafnode
BASICS
NoSQL and document databases
MONGODB
Document database, object store
REPLICATION AND
SHARDING
OOTB
GEOSPATIAL INDEX
JSON BSON
{

_id : ObjectId("51d66af57d3afb7a973b00ab"),

username : 'foo',

firstName : 'John',

lastName : 'Smith',

address : {

street : ‘5th N',

city : ‘New York',

zip : '00001'

}

friends : [ 'bill', 'frank', 'mike' ]

}
QUERIES
CRUD
FIND
INSERT
UPDATE
3 ways
REMOVE
PROJEKTOWANIE SCHEMATU
Schemaless != Don’t plan
RELATIONAL MODEL
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.'

}

]

}
GEOSPATIAL INDEX
db.places.ensureIndex( { location:‘2d’ } )
db.places.find( { location: { $near: [ 52, 21 ] } } )
MONGODB AND PHP
pecl install mongo
DEMO
DOCTRINE
DEMO
SIDENOTE
$qb = $dm->createQueryBuilder('Application_Model_Entry')
->field('club.$id')->equals(new MongoId($club->getId()));

MongoDB 101