Contenu connexe
Similaire à PostgreSQLからMongoDBへ (20)
Plus de Basuke Suzuki (7)
PostgreSQLからMongoDBへ
- 9. • PostgreSQL 7.4 => 8.1
• PHP 4.3 => 4.4 => 5.1
•
- 10. • MongoDB 1.6.3
• PHP 5.3
• Lithium
•
•
- 12. Lithium
• http://lithify.me/
• 5.3
• CakePHP
• MongoDB / CouchDB
• ↑ RDB w
- 13. PHP MongoDB
• Lithium
• pecl mongo
•
- 14. Item::find('all', array(
'conditions' => array(
'category' => $tag,
'visible' => true,
),
'order' => array(
'position'=>'DESC', 'id' => 'DESC'),
));
- 16. • mongoimport / mongoexport
• JSON
• JSON
• PHP
•
•
- 17. • mongoimport -d assiston -c items --drop --file
items.dump
{"no" : 123456, "items" : [{"at" : 1285679232000}}
- 18. Mongo Extended JSON
• http://www.mongodb.org/display/DOCS/Mongo
+Extended+JSON
• $binary, $date, $oid
• $date milliseconds
• PHP 32bit int
- 19. •
• PHP JSON
• TIMESTAMP json_encode
• '2010-12-10 17:20:21' => 1291969221
• 1291969221 sec => "||date:1291969221000||"
• JSON
• "||date:1291969221000||" => Date(1291969221000)
- 20. • PHP w
• Python OK
• pgmongo
- 22. CREATE TABLE ORDERS (
id SERIAL PRIMARY KEY,
total INTEGER NOT NULL, {
... no: integer,
); total: integer,
items: [
CREATE TABLE ORDER_ITEMS ( { price: integer, ...},
id SERIAL PRIMARY KEY,
]
order_id INTEGER
...
REFERS TO ORDERS,
}
price INTEGER NOT NULL,
...
);
- 23. 2:
• ObjectID
•
• function(seqname) { return
db.sequences.findAndModify({ query:{_id:seqname},
update: {$inc: {val:1}}, upsert: true, 'new': true}).val; }
• db.system.js
• db.eval("return sequence('abc')")
- 24. 3: mongo on github
• https://github.com/mongodb/mongo/tree/
master/jstests
• MongoDB JavaScript
Notes de l'éditeur
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n