MongoTalk/Voyage
by Nico and Esteban
Thursday, September 12, 13
Pre-requisites
• MongoDB installed and running
• Pharo 2.0
Thursday, September 12, 13
Getting MongoTalk
Gofer it
smalltalkhubUser:‘MongoTalkTeam’ project:
‘mongotalk’;
configurationOf:‘MongoTalk’;
load.
Configu...
What is Mongo?
• NoSQL database
• Opensource
• Document oriented
• Powerful query language
Thursday, September 12, 13
MongoTalk basics
• MongoTalk is a driver for Mongo
• JSON/BSON (dictionaries)
• Mongo databases, collections and
documents...
Let’s play with it!
• Creating a database
• Creating a collection
• Manipulating some documents
Thursday, September 12, 13
Databases and
collections
| mongo db users |
mongo := Mongo default open.
“db is created on the fly”
db := mongo databaseNa...
Insert/Update/Delete
users add: {
‘name’ -> ‘nico’.
‘age’ -> 27} asDictionary.
users
update: { ‘name’ -> ‘nico’ } asDictio...
Simple queries
“Use the traditional collection enumerating
methods, with dictionaries”
users select: {‘name’ -> ‘nico’} as...
Limit, offset, order
users
select: {‘name’ -> ‘nico’} asDictionary
limit: 5
offset: 10
order: {‘age’ -> 1} asDictionary
Th...
MongoQueries
users select: [ :each | each name = ‘nico’ ].
users detect: [ :each |
(each name = ‘nico’) & (each age > 25) ...
...Voyage
Thursday, September 12, 13
Install
Gofer it
smalltalkhubUser:‘estebanlm’ project:‘Voyage’;
configurationOf:‘VoyageMongo’;
load.
ConfigurationOfVoyageMo...
Singleton vs. Instanced
| repository |
repository :=VOMongoRepository
host:‘localhost’
database:‘esug’.
repository enableS...
Basic operation
| user |
user := User new
name:‘You’;
save.
user age:‘shhh’.
user save.
user remove.
Thursday, September 1...
Querying (1)
User selectAll.
User selectOne: [ :each | each name = ‘you’ ].
User selectMany: [ :each | each name = ‘you’ ]...
Querying (2)
User selectOne: {
#name -> ‘you’ } asDictionary.
User selectMany: {
#name -> ‘you’ } asDictionary.
Thursday, ...
Querying (3)
User
selectMany: { #name -> ‘you’ } asDictionary
sortBy: { #name ->VOOrder ascending }
limit: 10
offset: 10.
...
Querying (4)
User
selectMany: {
#name -> {
‘$regex’ -> ‘^y.*’.
‘$options’ -> ‘i’ } asDictionary } asDictionary
sortBy: { #...
References
• Embedded objects
• Regular references
• Cyclic
Thursday, September 12, 13
Customize (1)
User class>>#mongoContainer
<mongoContainer>
^VOMongoContainer new
collectionName:‘users’;
kind: User;
enabl...
Customize (2)
User class>>#mongoName
<mongoDescription>
^VOMongoToOneDescription new
attributeName:‘name’;
beLazy;
yoursel...
Customize (3)
User class>>#mongoGroups
<mongoDescription>
^VOMongoToManyDescription new
attributeName:‘groups’;
beEager;
k...
Customize (4)
User class>>#mongoName
<mongoDescription>
^VOMongoToOneDescription new
accessor: (MAPluggableAccessor
read: ...
Upcoming SlideShare
Loading in...5
×

MongoTalk/Voyage

816

Published on

MongoTalk/Voyage by Nico and Esteban

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
816
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

MongoTalk/Voyage

  1. 1. MongoTalk/Voyage by Nico and Esteban Thursday, September 12, 13
  2. 2. Pre-requisites • MongoDB installed and running • Pharo 2.0 Thursday, September 12, 13
  3. 3. Getting MongoTalk Gofer it smalltalkhubUser:‘MongoTalkTeam’ project: ‘mongotalk’; configurationOf:‘MongoTalk’; load. ConfigurationOfMongoTalk load. Thursday, September 12, 13
  4. 4. What is Mongo? • NoSQL database • Opensource • Document oriented • Powerful query language Thursday, September 12, 13
  5. 5. MongoTalk basics • MongoTalk is a driver for Mongo • JSON/BSON (dictionaries) • Mongo databases, collections and documents Thursday, September 12, 13
  6. 6. Let’s play with it! • Creating a database • Creating a collection • Manipulating some documents Thursday, September 12, 13
  7. 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
  8. 8. Insert/Update/Delete users add: { ‘name’ -> ‘nico’. ‘age’ -> 27} asDictionary. users update: { ‘name’ -> ‘nico’ } asDictionary with: { ‘name’ -> ‘nico’. ‘age’ -> 28 } asDictionary. users delete: {‘name’ -> ‘nico’ } asDictionary. Thursday, September 12, 13
  9. 9. Simple queries “Use the traditional collection enumerating methods, with dictionaries” users select: {‘name’ -> ‘nico’} asDictionary. users detect: {‘age’ -> 28} asDictionary. Thursday, September 12, 13
  10. 10. Limit, offset, order users select: {‘name’ -> ‘nico’} asDictionary limit: 5 offset: 10 order: {‘age’ -> 1} asDictionary Thursday, September 12, 13
  11. 11. MongoQueries users select: [ :each | each name = ‘nico’ ]. users detect: [ :each | (each name = ‘nico’) & (each age > 25) ] Thursday, September 12, 13
  12. 12. ...Voyage Thursday, September 12, 13
  13. 13. Install Gofer it smalltalkhubUser:‘estebanlm’ project:‘Voyage’; configurationOf:‘VoyageMongo’; load. ConfigurationOfVoyageMongo load. Thursday, September 12, 13
  14. 14. Singleton vs. Instanced | repository | repository :=VOMongoRepository host:‘localhost’ database:‘esug’. repository enableSingleton. Thursday, September 12, 13
  15. 15. Basic operation | user | user := User new name:‘You’; save. user age:‘shhh’. user save. user remove. Thursday, September 12, 13
  16. 16. Querying (1) User selectAll. User selectOne: [ :each | each name = ‘you’ ]. User selectMany: [ :each | each name = ‘you’ ]. Thursday, September 12, 13
  17. 17. Querying (2) User selectOne: { #name -> ‘you’ } asDictionary. User selectMany: { #name -> ‘you’ } asDictionary. Thursday, September 12, 13
  18. 18. Querying (3) User selectMany: { #name -> ‘you’ } asDictionary sortBy: { #name ->VOOrder ascending } limit: 10 offset: 10. Thursday, September 12, 13
  19. 19. Querying (4) User selectMany: { #name -> { ‘$regex’ -> ‘^y.*’. ‘$options’ -> ‘i’ } asDictionary } asDictionary sortBy: { #name ->VOOrder ascending } limit: 10 offset: 10. Thursday, September 12, 13
  20. 20. References • Embedded objects • Regular references • Cyclic Thursday, September 12, 13
  21. 21. Customize (1) User class>>#mongoContainer <mongoContainer> ^VOMongoContainer new collectionName:‘users’; kind: User; enableMissingContent; yourself Thursday, September 12, 13
  22. 22. Customize (2) User class>>#mongoName <mongoDescription> ^VOMongoToOneDescription new attributeName:‘name’; beLazy; yourself. Thursday, September 12, 13
  23. 23. Customize (3) User class>>#mongoGroups <mongoDescription> ^VOMongoToManyDescription new attributeName:‘groups’; beEager; kind: Group; kindCollection: Set; convertNullTo: [ MissingGroup new ]; yourself. Thursday, September 12, 13
  24. 24. Customize (4) User class>>#mongoName <mongoDescription> ^VOMongoToOneDescription new accessor: (MAPluggableAccessor read: [ :user | user nameForPersist ] write: [ :user :v | user name: v ]); yourself. Thursday, September 12, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×