REST Layer MongoDB Backend
Create a mgo master session:
session, err := mgo.Dial(url)
Create a resource storage handler with a given DB/collection:
s := mongo.NewHandler(session, "the_db", "the_collection")
Use this handler with a resource:
index.Bind("foo", foo, s, resource.DefaultConf)
You may want to create a many mongo handlers as you have resources as long as you want each resources in a different collection. You can share the same
mgo session across all you handlers.
This package also provides a REST Layer schema.Validator for MongoDB ObjectIDs. This validator ensures proper binary serialization of the Object ID in the database for space efficiency.
mongo.NewObjectID field hook and
mongo.ObjectIDField helper are also provided.