Пример #1
0
func get(s *gotalk.Sock, id bson.ObjectId) (*Person, error) {
	c := client.SockClient(s)
	fmt.Printf("GETREQUEST: [%s] [%+v] [%+v]\n", c.GoogleEmail, c, id)
	p := new(Person)
	err := coll.FindId(id).One(&p)
	if err != nil {
		return nil, err
	}
	return p, nil
}
Пример #2
0
func create(s *gotalk.Sock, r *Person) (*Person, error) {
	c := client.SockClient(s)
	fmt.Printf("CREATEREQUEST: [%s] [%+v] [%+v]\n", c.GoogleEmail, c, r)

	r.ID = db.NewObjectID()

	// FIXME: do other checks of this input...

	coll.Insert(r)

	return get(s, r.ID)
}