// SetAssetStatus sets the status for the given asset or returns an error if an invalid status was passed.
SetAssetStatus sets the status for the given asset or returns an error if an invalid status was passed.
// SetAssetStatus sets the status for the given asset or returns an error if an invalid status was passed .
func (db *DB) SetAssetStatus(awsName, status string) (*AssetInfo, error) {
	err := validateStatus(status)
	if err != nil {
		return nil, &ErrorInvalidStatus{Status: status}
	}
	assetInfoCollection := db.Client.Database(constants.AssetUploaderDatabaseName).Collection(constants.AssetUploaderCollectionName)
	opts := options.FindOneAndUpdate().SetReturnDocument(options.After)
	asset := &AssetInfo{}
	err = assetInfoCollection.FindOneAndUpdate(
		context.Background(),
		bson.M{
			"awsName": awsName,
		},
		bson.D{
			{"$set", bson.D{{"uploadStatus", status}}},
		}, opts,
	).Decode(asset)
	if err == mongo.ErrNoDocuments {
		return nil, &ErrorNoAssetFound{ID: awsName}
	}
	if err != nil {
		return nil, err
	}
	return asset, err
}
func ( db * DB ) SetAssetStatus ( awsName , status string ) ( * AssetInfo , error ) { err := validateStatus ( status ) if err != nil { return nil , & ErrorInvalidStatus { Status : status } } assetInfoCollection := db . Client . Database ( constants . AssetUploaderDatabaseName ) . Collection ( constants . AssetUploaderCollectionName ) opts := options . FindOneAndUpdate ( ) . SetReturnDocument ( options . After ) asset := & AssetInfo { } err = assetInfoCollection . FindOneAndUpdate ( context . Background ( ) , bson . M { " " : awsName , } , bson . D { { " " , bson . D { { " " , status } } } , } , opts , ) . Decode ( asset ) if err == mongo . ErrNoDocuments { return nil , & ErrorNoAssetFound { ID : awsName } } if err != nil { return nil , err } return asset , err }
SetAssetStatus sets the status for the given asset or returns an error if an invalid status was passed.
SetAssetStatus sets the status for the given asset or returns an error if an invalid status was passed .