Back

Creating new attribute for existing collection

  • 1
  • Databases
  • Web
  • Cloud
yaman
8 Jun, 2023, 19:08

I have an existing database collection. The collection already has multiple documents. I tried to add a new attribute called "rating" with default value of 0. The attribute was added in all documents but its value was set to "null" rather than 0. Isn't it a bug ? How to set it to 0 ?

TL;DR
The user wants to add a new attribute called "rating" with a default value of 0 to an existing database collection. However, when they tried to do so, the value of the attribute was set to "null" instead. They are asking if this is a bug and how to set the value to 0. The response states that this is an expected behavior in Appwrite and that the system does not automatically set values for old documents. The user is advised to use a server SDK to update the old documents. A link to a specific solution is provided in the response. Solution: Use a server SDK to update the old documents
Chola
8 Jun, 2023, 19:32

I noticed when i set a default boolean value in my collection i was also just getting null, even from the console it didn't reflect. Looks like a bug, let's see what the Pro's have to say

Drake
9 Jun, 2023, 01:07

This is expected. Appwrite doesn't automatically set the value for old documents. You can use a server SDK to update old documents:

https://github.com/appwrite/appwrite/issues/2768#issuecomment-1506322491

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more