Exemple #1
0
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
}
Exemple #2
0
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
}