func (m *MongoDataSource) PutThing(t *api.Thing) api.Thing { session := m.session.Copy() defer session.Close() c := session.DB("devices").C("devices") t.DatabaseId = bson.NewObjectId() t.Descriptor = api.ThingType{} err := c.Insert(&t) if err != nil { log.Println(err) } return *t }