// Retrieve gets the specified product from the database.
Retrieve gets the specified product from the database.
// Retrieve gets the specified product from the database .
func Retrieve(ctx context.Context, dbConn *db.DB, id string) (*Product, error) {
	ctx, span := trace.StartSpan(ctx, "internal.product.Retrieve")
	defer span.End()
	if !bson.IsObjectIdHex(id) {
		return nil, ErrInvalidID
	}
	q := bson.M{"_id": bson.ObjectIdHex(id)}
	var p *Product
	f := func(collection *mgo.Collection) error {
		return collection.Find(q).One(&p)
	}
	if err := dbConn.Execute(ctx, productsCollection, f); err != nil {
		if err == mgo.ErrNotFound {
			return nil, ErrNotFound
		}
		return nil, errors.Wrap(err, fmt.Sprintf("db.products.find(%s)", db.Query(q)))
	}
	return p, nil
}
func Retrieve ( ctx context . Context , dbConn * db . DB , id string ) ( * Product , error ) { ctx , span := trace . StartSpan ( ctx , " " ) defer span . End ( ) if ! bson . IsObjectIdHex ( id ) { return nil , ErrInvalidID } q := bson . M { " " : bson . ObjectIdHex ( id ) } var p * Product f := func ( collection * mgo . Collection ) error { return collection . Find ( q ) . One ( & p ) } if err := dbConn . Execute ( ctx , productsCollection , f ) ; err != nil { if err == mgo . ErrNotFound { return nil , ErrNotFound } return nil , errors . Wrap ( err , fmt . Sprintf ( " " , db . Query ( q ) ) ) } return p , nil }
Retrieve gets the specified product from the database.
Retrieve gets the specified product from the database .