func (o *DefaultThingManager) RegisterThing(d api.Thing) { descriptor, err := o.GetThingType(d.Type) if err != nil { log.Println(err) } d.Descriptor = descriptor o.things[d.GetId()] = d }
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 }