Skip to content

Commit 56d8123

Browse files
Merge pull request #398 from geturbackend/mintlify/18e5b791
Update from code changes: document collection field defaults
2 parents d42939b + 19c4c51 commit 56d8123

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎mintlify/docs/concepts/collections-schemas.mdx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,31 @@ Mark a field as **required** in the dashboard to prevent documents from being sa
8181

8282
Mark a field as **unique** to enforce that no two documents in the collection share the same value for that field. This is enforced at the database level and is useful for fields like `username` or `email` in custom collections.
8383

84+
### Default values
85+
86+
Set a **default** on any non-required `String`, `Number`, or `Boolean` field. When a document is inserted without that field, urBackend stores the default value instead of leaving it unset.
87+
88+
Defaults are available in both the manual collection builder and the AI Collection Creator. In the manual builder, the `Default` column appears next to each field row and accepts a value that matches the field's type. In the AI Collection Creator, defaults are proposed automatically for optional fields where they make sense.
89+
90+
Rules:
91+
92+
- Defaults are only supported on `String`, `Number`, and `Boolean` fields. `Date`, `Ref`, `Array`, and `Object` fields cannot have defaults.
93+
- Defaults are only allowed on non-required fields. Marking a field as required clears any default that was set.
94+
- The default value's type must match the field type — a `Number` field cannot default to a string.
95+
96+
## Collections must have at least one field
97+
98+
A collection must be created with at least one field. Requests to create or edit a collection with an empty schema are rejected with `400`:
99+
100+
```json
101+
{
102+
"success": false,
103+
"message": "At least one field is required"
104+
}
105+
```
106+
107+
The dashboard blocks the **Save Collection** action when no fields are defined, and the AI Collection Creator will not finalize an empty schema.
108+
84109
## Field type examples
85110

86111
### String

0 commit comments

Comments
 (0)