This document provides an introduction and overview of MongoTalk and Voyage, two Smalltalk libraries for interacting with MongoDB databases. It demonstrates how to install, configure, and perform basic operations like creating databases and collections, inserting, updating, deleting and querying documents with both libraries. It also shows how to customize mappings and relationships when using Voyage.
4. What is Mongo?
• NoSQL database
• Opensource
• Document oriented
• Powerful query language
Thursday, September 12, 13
5. MongoTalk basics
• MongoTalk is a driver for Mongo
• JSON/BSON (dictionaries)
• Mongo databases, collections and
documents
Thursday, September 12, 13
6. Let’s play with it!
• Creating a database
• Creating a collection
• Manipulating some documents
Thursday, September 12, 13
7. Databases and
collections
| mongo db users |
mongo := Mongo default open.
“db is created on the fly”
db := mongo databaseNamed:‘esug’.
“Same goes for collections”
users := db addCollection:‘users’.
Thursday, September 12, 13
14. Singleton vs. Instanced
| repository |
repository :=VOMongoRepository
host:‘localhost’
database:‘esug’.
repository enableSingleton.
Thursday, September 12, 13
15. Basic operation
| user |
user := User new
name:‘You’;
save.
user age:‘shhh’.
user save.
user remove.
Thursday, September 12, 13
16. Querying (1)
User selectAll.
User selectOne: [ :each | each name = ‘you’ ].
User selectMany: [ :each | each name = ‘you’ ].
Thursday, September 12, 13
17. Querying (2)
User selectOne: {
#name -> ‘you’ } asDictionary.
User selectMany: {
#name -> ‘you’ } asDictionary.
Thursday, September 12, 13