#Removing Editing Metadata of Product Not Working

34 messages · Page 1 of 1 (latest)

velvet hound
#

Sending Post request with edited metadata field doesn't update it on the backend

I added a metadata section to the product edit page where I can edit the metadata just like in collections, I successfully added metadata fields to the product but I'm unable to delete or edit the fields I added (I checked that the POST request contains the changed metadata)

simple cradle
#

Which version of medusa are you using?

velvet hound
#

1.6.0

simple cradle
#

Can you upgrade to the latest as I think it has been fixed in the mean time

velvet hound
#

I think 1.6 is what comes with the starter

#

ok

#

BTW how can I upgrade all packages at once, I tried npm i @medusajs/medusa but I get a conflicting peer dependency

simple cradle
#

You can see the newest version with nom outdated and then proceed with npm update. Theoretically it should do the job.

#

For specific packages you can do npm update ´package1’ ´package2´

#

Don’t forget to read about the upgrade guide when you switch medusa versions

velvet hound
#

Do I need to go over all upgrade guides from the version I'm on till the newest version (1.6.1 - 1.7.6)?

gusty hare
#

except careful as npm update might update typorm to 0.3

#

not sure, I alwayuse ncu for that

#

ncu -u -x typeorm

#

or lock down typeorm in package.json

simple cradle
#

Yeah typeorm must not be upgraded, it has to be fixed. You can remove the ^ if it is present and just fix the version to avoid any involuntary update

#

For the upgrade guide i suggest you to have a look at them just to see if you need in your case to run some scripts or not, but you will have to run the migrations

#

Typeorm 3 will come in the next minor version 🙏

velvet hound
#

Thank you so much

velvet hound
#

just to make sure, do I need to upgrade from 1.6 to 1.6.1 then 1.7.0,....,1.7.6 and run each migration or directly from 1.6 to 1.7.6? Because if I upgrade incrementally I will also need to upgrade peer packages incrementally

simple cradle
#

You should be able to upgrade directly to the latest, but you’ll have to run all migrations and see if you need to run the scripts depending on your context/data/advancement

velvet hound
#

Thanks for the clarification

velvet hound
#

It seems that removing or editing an existing metadata field in collections and products isn't possible 🥲

simple cradle
velvet hound
#

you're right I just tried that 👍

#

but two inconsistencies I find are:

  • editing an existing key created a new key with the same value
  • when creating a new product a key with an empty value was added successfully but when editing a product you can't add a key with an empty value
#

I'm not sure if these are considered inconsistencies, but I wasn't expecting them to happen 🙂

simple cradle
#
  • An object can’t have two identical keys, an object type does not allow that, they are unique, if a key already exists then the value will be assigned to that key as you can see in the code. could you share your metadata please
  • when creating, it is normal that you can add an empty value, but for the update we use empty value as an identifier for removal so that you can still set null for example, so this is expected
#

I ll have to go to bed, i ll read your answer later 👍

velvet hound
#

For the first one I meant (In case I want to edit an existing key name) for example from
{"brands": "value1"} to {"brand":"value1"} I will have two fields instead of one that I expected to be edited

simple cradle
#

In that case you do brands: ‘’, brand: ‘value 1’, this is how object works, you can’t provide a key to replace another key as it is considered as a different one.

#

It will remove brands and brand will be added

#

Or using the existing value it would looks like:

metadata.brand = metadata.brands
metadata.brands = ‘’