MongoTalk/Voyage
Upcoming SlideShare
Loading in...5
×
 

MongoTalk/Voyage

on

  • 985 views

MongoTalk/Voyage by Nico and Esteban

MongoTalk/Voyage by Nico and Esteban

Statistics

Views

Total Views
985
Views on SlideShare
982
Embed Views
3

Actions

Likes
1
Downloads
9
Comments
0

1 Embed 3

https://twitter.com 3

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MongoTalk/Voyage MongoTalk/Voyage Presentation Transcript

    • 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. ConfigurationOfMongoTalk load. Thursday, September 12, 13
    • 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 Thursday, September 12, 13
    • 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 databaseNamed:‘esug’. “Same goes for collections” users := db addCollection:‘users’. Thursday, September 12, 13
    • 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
    • Simple queries “Use the traditional collection enumerating methods, with dictionaries” users select: {‘name’ -> ‘nico’} asDictionary. users detect: {‘age’ -> 28} asDictionary. Thursday, September 12, 13
    • Limit, offset, order users select: {‘name’ -> ‘nico’} asDictionary limit: 5 offset: 10 order: {‘age’ -> 1} asDictionary Thursday, September 12, 13
    • MongoQueries users select: [ :each | each name = ‘nico’ ]. users detect: [ :each | (each name = ‘nico’) & (each age > 25) ] Thursday, September 12, 13
    • ...Voyage Thursday, September 12, 13
    • Install Gofer it smalltalkhubUser:‘estebanlm’ project:‘Voyage’; configurationOf:‘VoyageMongo’; load. ConfigurationOfVoyageMongo load. Thursday, September 12, 13
    • Singleton vs. Instanced | repository | repository :=VOMongoRepository host:‘localhost’ database:‘esug’. repository enableSingleton. Thursday, September 12, 13
    • Basic operation | user | user := User new name:‘You’; save. user age:‘shhh’. user save. user remove. Thursday, September 12, 13
    • Querying (1) User selectAll. User selectOne: [ :each | each name = ‘you’ ]. User selectMany: [ :each | each name = ‘you’ ]. Thursday, September 12, 13
    • Querying (2) User selectOne: { #name -> ‘you’ } asDictionary. User selectMany: { #name -> ‘you’ } asDictionary. Thursday, September 12, 13
    • Querying (3) User selectMany: { #name -> ‘you’ } asDictionary sortBy: { #name ->VOOrder ascending } limit: 10 offset: 10. Thursday, September 12, 13
    • Querying (4) User selectMany: { #name -> { ‘$regex’ -> ‘^y.*’. ‘$options’ -> ‘i’ } asDictionary } asDictionary sortBy: { #name ->VOOrder ascending } limit: 10 offset: 10. Thursday, September 12, 13
    • References • Embedded objects • Regular references • Cyclic Thursday, September 12, 13
    • Customize (1) User class>>#mongoContainer <mongoContainer> ^VOMongoContainer new collectionName:‘users’; kind: User; enableMissingContent; yourself Thursday, September 12, 13
    • Customize (2) User class>>#mongoName <mongoDescription> ^VOMongoToOneDescription new attributeName:‘name’; beLazy; yourself. Thursday, September 12, 13
    • Customize (3) User class>>#mongoGroups <mongoDescription> ^VOMongoToManyDescription new attributeName:‘groups’; beEager; kind: Group; kindCollection: Set; convertNullTo: [ MissingGroup new ]; yourself. Thursday, September 12, 13
    • 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