fun key: String is abstract
# Saves `self` in db.
- fun save do game.db.collection(collection_name).save(to_json)
+ fun save do game.db.collection(collection_name).save(to_json_object)
# Json representation of `self`.
- fun to_json: JsonObject do
+ fun to_json_object: JsonObject do
var json = new JsonObject
json["_id"] = key
return json
redef var key = name is lazy
# Mongo server url where this game data are stored.
- var mongo_url = "mongodb://localhost:27017" is writable
+ var mongo_url = "mongodb://mongo:27017" is writable
# Mongo db client.
var client = new MongoClient(mongo_url) is lazy
# Used to load entities from saved data.
fun from_json(json: JsonObject) do end
- redef fun to_json do
+ redef fun to_json_object do
var json = super
json["name"] = name
return json
end
# Erase all saved data for this game.
- fun clear do db.collection(collection_name).remove(to_json)
+ fun clear do db.collection(collection_name).remove(to_json_object)
# Verbosity level used fo stdout.
#
nitcoins = json["nitcoins"].as(Int)
end
- redef fun to_json do
+ redef fun to_json_object do
var json = super
json["game"] = game.key
json["name"] = name