# wixData Insert creates rows without default values

**URL:** <https://forum.wixstudio.com/t/wixdata-insert-creates-rows-without-default-values/61262>\
**Category:** Ask the community\
**Tags:** wix-data, code, question, wix\
**Created:** [July 29, 2024, 11:40pm UTC](https://forum.wixstudio.com/t/wixdata-insert-creates-rows-without-default-values/61262 "2024-07-29T23:40:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Jones](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brian_jones/32/94933_2.png) [@Brian\_Jones](https://forum.wixstudio.com/u/Brian_Jones)\
**Post date:** [July 29, 2024, 11:40pm UTC](https://forum.wixstudio.com/t/wixdata-insert-creates-rows-without-default-values/61262/1 "2024-07-29T23:40:51Z")

</div>

**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.

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [July 30, 2024, 2:06am UTC](https://forum.wixstudio.com/t/wixdata-insert-creates-rows-without-default-values/61262/2 "2024-07-30T02:06:49Z")

</div>

Hi Brian\_Jones,

You can definitely set default values directly in your `toInsert` object as you’ve shown. Here’s how it looks:

```javascript
var toInsert = {
  'requestData': { …request stuff in here… },
  'requestType': "FromAppBackground",
  'retryCount': 0, // Default value
  'status': "Pending" // Default value
};
wixData.insert("Requests", toInsert)

```
