Your SlideShare is downloading. ×
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
MongoTalk/Voyage
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MongoTalk/Voyage

755

Published on

MongoTalk/Voyage by Nico and Esteban

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
755
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MongoTalk/Voyage by Nico and Esteban Thursday, September 12, 13
  • 2. Pre-requisites • MongoDB installed and running • Pharo 2.0 Thursday, September 12, 13
  • 3. Getting MongoTalk Gofer it smalltalkhubUser:‘MongoTalkTeam’ project: ‘mongotalk’; configurationOf:‘MongoTalk’; load. ConfigurationOfMongoTalk load. Thursday, September 12, 13
  • 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
  • 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. 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. Limit, offset, order users select: {‘name’ -> ‘nico’} asDictionary limit: 5 offset: 10 order: {‘age’ -> 1} asDictionary Thursday, September 12, 13
  • 11. MongoQueries users select: [ :each | each name = ‘nico’ ]. users detect: [ :each | (each name = ‘nico’) & (each age > 25) ] Thursday, September 12, 13
  • 12. ...Voyage Thursday, September 12, 13
  • 13. Install Gofer it smalltalkhubUser:‘estebanlm’ project:‘Voyage’; configurationOf:‘VoyageMongo’; load. ConfigurationOfVoyageMongo load. 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
  • 18. Querying (3) User selectMany: { #name -> ‘you’ } asDictionary sortBy: { #name ->VOOrder ascending } limit: 10 offset: 10. Thursday, September 12, 13
  • 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. References • Embedded objects • Regular references • Cyclic Thursday, September 12, 13
  • 21. Customize (1) User class>>#mongoContainer <mongoContainer> ^VOMongoContainer new collectionName:‘users’; kind: User; enableMissingContent; yourself Thursday, September 12, 13
  • 22. Customize (2) User class>>#mongoName <mongoDescription> ^VOMongoToOneDescription new attributeName:‘name’; beLazy; yourself. Thursday, September 12, 13
  • 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. 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

×