Configure Store
In this section we will learn how to use MongoDB (a document-oriented database) and PostgreSQL (a object-relational database system).
Steam uses Voyage as a layer between the objects and a persistency mechanism for Mongo. Voyage is a persistence framework.
To begin with you have to install it on your computer first. You can find a documentation here.
Then to run it, open a terminal and execute mongod you may need to put sudo before sudo mongod.
With voyage we can store easily objects even complex ones because MongoDB is a document-oriented database.
Steam uses Glorp and Garage in order to support PostgreSQL. Glorp is the Object-Relational-Mapper for Smalltalk and Garage is the relational database driver for Pharo.
For PostgreSql you can find a documentation here.
With Glorp it's difficult to take advantage of object's inheritance, so we are limeted to store simple objects.
This is very easy, you simply have to override the method GameManager >> createNewStore to configure the store you want to use.
GameManager >> createNewStore
^ STMemoryStore on: selfGameManager >> createNewStore
^ STMongoStore
on: self
host: 'localhost' "here the host url of your DB"
database: 'steam' "here the name of your DB"GameManager >> createNewStore
^ STPostgresSQLStore
on: self
username: '' "your user name"
password: '' "your password"
host: 'localhost' "the host url of your DB"
port: '5432' "the port you're using (optionnal)"
database: '' "the name of the DB you're using"Also we need to specify the classes we want to use like this :
GameManager >> applicationClasses
^ {GMCategory. GMGame}
After the installation and configuration of the PostgreSQL Store you have to create tables by executing GameManager new store createTables
If you want to drop tables you can run GameManager new store dropTables.