// Delete removes a product from the database.
Delete removes a product from the database.
// Delete removes a product from the database .
func Delete(ctx context.Context, dbConn *db.DB, id string) error {
	ctx, span := trace.StartSpan(ctx, "internal.product.Delete")
	defer span.End()
	if !bson.IsObjectIdHex(id) {
		return ErrInvalidID
	}
	q := bson.M{"_id": bson.ObjectIdHex(id)}
	f := func(collection *mgo.Collection) error {
		return collection.Remove(q)
	}
	if err := dbConn.Execute(ctx, productsCollection, f); err != nil {
		if err == mgo.ErrNotFound {
			err = ErrNotFound
		}
		return errors.Wrap(err, fmt.Sprintf("db.products.remove(%v)", q))
	}
	return nil
}
func Delete ( ctx context . Context , dbConn * db . DB , id string ) error { ctx , span := trace . StartSpan ( ctx , " " ) defer span . End ( ) if ! bson . IsObjectIdHex ( id ) { return ErrInvalidID } q := bson . M { " " : bson . ObjectIdHex ( id ) } f := func ( collection * mgo . Collection ) error { return collection . Remove ( q ) } if err := dbConn . Execute ( ctx , productsCollection , f ) ; err != nil { if err == mgo . ErrNotFound { err = ErrNotFound } return errors . Wrap ( err , fmt . Sprintf ( " " , q ) ) } return nil }
Delete removes a product from the database.
Delete removes a product from the database .