Question:
When inserting rows into our collections using insert, the insert command will create items with the values passed in, but if a field was set with a default value, that value is left as null. For example, a table called Requests with the following fields
RequestData - json object, no default
RequestType - text, no default
RetryCount - number, default 0
Status - text, default is “Pending”
If I use the following code
var toInsert = {
‘requestData’: {…request stuff in here…},
‘requestType’: “FromAppBackground”,
};
wixData.insert(“Requests”, toInsert)
I expect the collection to have a new row with the two values I passed in, and the Status and RetryCount fields to be populated with the default value. Instead, only the two fields passed in are defined while the two fields with default values are null. I wouldn’t expect that I would need to explicitly set those fields on the insert since that’s what default values are there for.
Product:
Wix Editor
What are you trying to achieve:
Trying to allow default values to work as expected so my insert code can be cleaner.
What have you already tried:
I can get around this by just explicitly defining EVERY field in the insert, but that seems counterintuitive to having defaults.